<commit_before>#include <dlfcn.h>
#include "scaf.h"
#include "../config.h"
#include <pthread.h>

/* Used to generate a string to pass to dlsym */
#define __STRINGIFY(X) #X
#define STRINGIFY(X) __STRINGIFY(X)

/* Describe the functions we are wrapping.
 * libgomp from GCC < 4.9 have GOMP_parallel_{start,stop}. */
#define __scaf_SECTION_START GOMP_parallel_start
#define __scaf_SECTION_START_RET void
#define __scaf_SECTION_START_FORMAL_ARGS                                       \
    void (*fn)(void *), void *data, unsigned num_threads
#define __scaf_SECTION_START_ACTUAL_ARGS fn, data, num_threads
#define __scaf_SECTION_START_ACTUAL_ARGS_1_2 fn, data
#define __scaf_SECTION_START_ACTUAL_ARGS_1 fn
#define __scaf_SECTION_START_ACTUAL_ARGS_2 data
#define __scaf_SECTION_END GOMP_parallel_end
#define __scaf_SECTION_END_RET void
#define __scaf_SECTION_END_FORMAL_ARGS void
#define __scaf_SECTION_END_ACTUAL_ARGS void
/* libgomp from GCC >= 4.9 have a single GOMP_parallel call that does both
 * start/stop and runs the master thread's workload in between. */
#define __scaf_SECTION_BOTH GOMP_parallel
#define __scaf_SECTION_BOTH_RET void
#define __scaf_SECTION_BOTH_FORMAL_ARGS                                        \
    void (*fn)(void *), void *data, unsigned num_threads, unsigned int flags
#define __scaf_SECTION_BOTH_ACTUAL_ARGS fn, data, num_threads, flags
#define __scaf_SECTION_BOTH_ACTUAL_ARGS_1_2 fn, data
#define __scaf_SECTION_BOTH_ACTUAL_ARGS_1 fn
#define __scaf_SECTION_BOTH_ACTUAL_ARGS_2 data
#define __scaf_SECTION_BOTH_ACTUAL_ARGS_3 num_threads
#define __scaf_SECTION_BOTH_ACTUAL_ARGS_4 flags
/* Both versions have get/set_num_threads routines. We also hijack these in
 * order to detect non-malleable processes. */
#define __scaf_GET_THREADS omp_get_num_threads
#define __scaf_GET_THREADS_RET int
#define __scaf_GET_THREADS_FORMAL_ARGS void
#define __scaf_SET_THREADS omp_set_num_threads
#define __scaf_SET_THREADS_RET void
#define __scaf_SET_THREADS_FORMAL_ARGS int n
#define __scaf_SET_THREADS_ACTUAL_ARGS n

/* Local pointers to the actual functions which we still want to eventually
 * call */
static __scaf_SECTION_START_RET (*__real_start)(
    __scaf_SECTION_START_FORMAL_ARGS) = NULL;
static __scaf_SECTION_END_RET (*__real_end)(__scaf_SECTION_END_FORMAL_ARGS) =
    NULL;
static __scaf_GET_THREADS_RET (*__real_get_threads)(
    __scaf_GET_THREADS_FORMAL_ARGS) = NULL;
static __scaf_SET_THREADS_RET (*__real_set_threads)(
    __scaf_SET_THREADS_FORMAL_ARGS) = NULL;

/* Pointer to my discovered process name. Used only for hacky malleability
 * whitelisting */
#if(HAVE_PROGNAME)
extern const char *__progname;
#define __scaf_PROGNAME (__progname)
#else
#define __scaf_PROGNAME ((void *)0)
#endif<commit_msg>scafwrap: remove redundancy in convenience macros<commit_after>#include <dlfcn.h>
#include "scaf.h"
#include "../config.h"
#include <pthread.h>

/* Used to generate a string to pass to dlsym */
#define __STRINGIFY(X) #X
#define STRINGIFY(X) __STRINGIFY(X)

/* Describe the functions we are wrapping.
 * libgomp from GCC < 4.9 have GOMP_parallel_{start,stop}. */
#define __scaf_SECTION_START GOMP_parallel_start
#define __scaf_SECTION_START_RET void
#define __scaf_SECTION_START_FORMAL_ARGS                                       \
    void (*fn)(void *), void *data, unsigned num_threads
#define __scaf_SECTION_START_ACTUAL_ARGS_1 fn
#define __scaf_SECTION_START_ACTUAL_ARGS_2 data
#define __scaf_SECTION_START_ACTUAL_ARGS_3 num_threads
#define __scaf_SECTION_START_ACTUAL_ARGS_1_2 __scaf_SECTION_START_ACTUAL_ARGS_1, __scaf_SECTION_START_ACTUAL_ARGS_2
#define __scaf_SECTION_START_ACTUAL_ARGS __scaf_SECTION_START_ACTUAL_ARGS_1, __scaf_SECTION_START_ACTUAL_ARGS_2, __scaf_SECTION_START_ACTUAL_ARGS_3
#define __scaf_SECTION_END GOMP_parallel_end
#define __scaf_SECTION_END_RET void
#define __scaf_SECTION_END_FORMAL_ARGS void
#define __scaf_SECTION_END_ACTUAL_ARGS void
/* libgomp from GCC >= 4.9 have a single GOMP_parallel call that does both
 * start/stop and runs the master thread's workload in between. */
#define __scaf_SECTION_BOTH GOMP_parallel
#define __scaf_SECTION_BOTH_RET void
#define __scaf_SECTION_BOTH_FORMAL_ARGS                                        \
    void (*fn)(void *), void *data, unsigned num_threads, unsigned int flags
#define __scaf_SECTION_BOTH_ACTUAL_ARGS_1 fn
#define __scaf_SECTION_BOTH_ACTUAL_ARGS_2 data
#define __scaf_SECTION_BOTH_ACTUAL_ARGS_3 num_threads
#define __scaf_SECTION_BOTH_ACTUAL_ARGS_4 flags
#define __scaf_SECTION_BOTH_ACTUAL_ARGS_1_2 __scaf_SECTION_BOTH_ACTUAL_ARGS_1, __scaf_SECTION_BOTH_ACTUAL_ARGS_2
#define __scaf_SECTION_BOTH_ACTUAL_ARGS __scaf_SECTION_BOTH_ACTUAL_ARGS_1, __scaf_SECTION_BOTH_ACTUAL_ARGS_2, __scaf_SECTION_BOTH_ACTUAL_ARGS_3, __scaf_SECTION_BOTH_ACTUAL_ARGS_4
/* Both versions have get/set_num_threads routines. We also hijack these in
 * order to detect non-malleable processes. */
#define __scaf_GET_THREADS omp_get_num_threads
#define __scaf_GET_THREADS_RET int
#define __scaf_GET_THREADS_FORMAL_ARGS void
#define __scaf_SET_THREADS omp_set_num_threads
#define __scaf_SET_THREADS_RET void
#define __scaf_SET_THREADS_FORMAL_ARGS int n
#define __scaf_SET_THREADS_ACTUAL_ARGS n

/* Local pointers to the actual functions which we still want to eventually
 * call */
static __scaf_SECTION_START_RET (*__real_start)(
    __scaf_SECTION_START_FORMAL_ARGS) = NULL;
static __scaf_SECTION_END_RET (*__real_end)(__scaf_SECTION_END_FORMAL_ARGS) =
    NULL;
static __scaf_GET_THREADS_RET (*__real_get_threads)(
    __scaf_GET_THREADS_FORMAL_ARGS) = NULL;
static __scaf_SET_THREADS_RET (*__real_set_threads)(
    __scaf_SET_THREADS_FORMAL_ARGS) = NULL;

/* Pointer to my discovered process name. Used only for hacky malleability
 * whitelisting */
#if(HAVE_PROGNAME)
extern const char *__progname;
#define __scaf_PROGNAME (__progname)
#else
#define __scaf_PROGNAME ((void *)0)
#endif
{'fraction_non_alphanumeric': 0.06048250084947333, 'fraction_numerical': 0.007135575942915392, 'mean_word_length': 6.294919454770756, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5032597', 'n_tokens_mistral': 2185, 'n_tokens_neox': 2141, 'n_words': 469}