diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:35 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:35 -0800 |
commit | dfb3f050a7cebd2030ea23dc6fa8964530e4ddcc (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /libutil | |
parent | b9958da7adae1c7d4482e958b371401eef387a39 (diff) | |
download | oprofile-dfb3f050a7cebd2030ea23dc6fa8964530e4ddcc.tar.gz |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'libutil')
-rw-r--r-- | libutil/Android.mk | 21 | ||||
-rw-r--r-- | libutil/fscanf.c | 22 | ||||
-rw-r--r-- | libutil/op_cpufreq.c | 64 | ||||
-rw-r--r-- | libutil/op_cpufreq.h | 30 | ||||
-rw-r--r-- | libutil/op_deviceio.c | 42 | ||||
-rw-r--r-- | libutil/op_deviceio.h | 57 | ||||
-rw-r--r-- | libutil/op_file.c | 185 | ||||
-rw-r--r-- | libutil/op_file.h | 109 | ||||
-rw-r--r-- | libutil/op_fileio.c | 228 | ||||
-rw-r--r-- | libutil/op_fileio.h | 140 | ||||
-rw-r--r-- | libutil/op_get_time.c | 24 | ||||
-rw-r--r-- | libutil/op_get_time.h | 33 | ||||
-rw-r--r-- | libutil/op_growable_buffer.c | 46 | ||||
-rw-r--r-- | libutil/op_growable_buffer.h | 45 | ||||
-rw-r--r-- | libutil/op_libiberty.c | 38 | ||||
-rw-r--r-- | libutil/op_libiberty.h | 81 | ||||
-rw-r--r-- | libutil/op_list.h | 177 | ||||
-rw-r--r-- | libutil/op_lockfile.c | 69 | ||||
-rw-r--r-- | libutil/op_lockfile.h | 34 | ||||
-rw-r--r-- | libutil/op_popt.c | 43 | ||||
-rw-r--r-- | libutil/op_popt.h | 42 | ||||
-rw-r--r-- | libutil/op_string.c | 62 | ||||
-rw-r--r-- | libutil/op_string.h | 81 | ||||
-rw-r--r-- | libutil/op_types.h | 37 | ||||
-rw-r--r-- | libutil/op_version.c | 24 | ||||
-rw-r--r-- | libutil/op_version.h | 26 |
26 files changed, 0 insertions, 1760 deletions
diff --git a/libutil/Android.mk b/libutil/Android.mk deleted file mode 100644 index 29f3bfb..0000000 --- a/libutil/Android.mk +++ /dev/null @@ -1,21 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - op_cpufreq.c \ - op_deviceio.c \ - op_file.c \ - op_fileio.c \ - op_get_time.c \ - op_libiberty.c \ - op_lockfile.c \ - op_popt.c \ - op_string.c \ - op_version.c - -LOCAL_C_INCLUDES := \ - $(LOCAL_PATH)/.. - -LOCAL_MODULE := libutil - -include $(BUILD_STATIC_LIBRARY) diff --git a/libutil/fscanf.c b/libutil/fscanf.c deleted file mode 100644 index d567324..0000000 --- a/libutil/fscanf.c +++ /dev/null @@ -1,22 +0,0 @@ -#include <stdio.h> - -// ugly hack because we don't have fscanf - -int fscanf(FILE* stream, const char* format, int* value) -{ - int c; - int r = 0; - do { - c = fgetc(stream); - if (c>='0' && c<='9') { - r = r*10 + (c-'0'); - continue; - } - break; - } while (1); - - *value = r; - - // gahhhh - return 1; -} diff --git a/libutil/op_cpufreq.c b/libutil/op_cpufreq.c deleted file mode 100644 index 78a6333..0000000 --- a/libutil/op_cpufreq.c +++ /dev/null @@ -1,64 +0,0 @@ -/** - * @file op_cpufreq.c - * get cpu frequency definition - * - * @remark Copyright 2003 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#include <stdio.h> -#include <stdlib.h> - -#include "op_fileio.h" - -double op_cpu_frequency(void) -{ - double fval = 0.0; - unsigned long uval; - char * line = NULL; - - FILE * fp = op_try_open_file("/proc/cpuinfo", "r"); - if (!fp) - return 0.0; - - while (1) { - line = op_get_line(fp); - - if (!line) - break; - - if (line[0] == '\0') { - free(line); - continue; - } - - /* x86/parisc/ia64/x86_64 */ - if (sscanf(line, "cpu MHz : %lf", &fval) == 1) - break; - /* ppc/ppc64 */ - if (sscanf(line, "clock : %lfMHz", &fval) == 1) - break; - /* alpha */ - if (sscanf(line, "cycle frequency [Hz] : %lu", &uval) == 1) { - fval = uval / 1E6; - break; - } - /* sparc64 if CONFIG_SMP only */ - if (sscanf(line, "Cpu0ClkTck : %lx", &uval) == 1) { - fval = uval / 1E6; - break; - } - /* s390 doesn't provide cpu freq, checked up to 2.6-test4 */ - - free(line); - } - - if (line) - free(line); - op_close_file(fp); - - return fval; -} diff --git a/libutil/op_cpufreq.h b/libutil/op_cpufreq.h deleted file mode 100644 index 0a71172..0000000 --- a/libutil/op_cpufreq.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @file op_cpufreq.h - * get cpu frequency declaration - * - * @remark Copyright 2003 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_CPUFREQ_H -#define OP_CPUFREQ_H - -#if defined(__cplusplus) -extern "C" { -#endif - -/* - * return the estimated cpu frequency in Mhz through - * parsing /proc/cpuinfo, return 0 if this information - * is not avalaible e.g. sparc64 with a non SMP kernel - */ -double op_cpu_frequency(void); - -#if defined(__cplusplus) -} -#endif - -#endif /* !OP_CPUFREQ_H */ diff --git a/libutil/op_deviceio.c b/libutil/op_deviceio.c deleted file mode 100644 index 8210304..0000000 --- a/libutil/op_deviceio.c +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file op_deviceio.c - * Reading from a special device - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#include "op_deviceio.h" - -#include <sys/types.h> -#include <fcntl.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> - -fd_t op_open_device(char const * name) -{ - return open(name, O_RDONLY); -} - - -ssize_t op_read_device(fd_t devfd, void * buf, size_t size) -{ - ssize_t count; - - lseek(devfd, 0, SEEK_SET); - - count = read(devfd, buf, size); - - if (count < 0 && errno != EINTR && errno != EAGAIN) { - perror("oprofiled:op_read_device: "); - exit(EXIT_FAILURE); - } - - return count; -} diff --git a/libutil/op_deviceio.h b/libutil/op_deviceio.h deleted file mode 100644 index f3bd4c2..0000000 --- a/libutil/op_deviceio.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @file op_deviceio.h - * Reading from a special device - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_DEVICEIO_H -#define OP_DEVICEIO_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "op_types.h" - -#include <unistd.h> - -/** - * op_open_device - open a special char device for reading - * @param name file name of device file - * - * Open the special file name. Returns the file descriptor - * for the file or -1 on error. - */ -fd_t op_open_device(char const * name); - -/** - * op_read_device - read from a special char device - * @param devfd file descriptor of device - * @param buf buffer - * @param size size of buffer - * - * Read size bytes from a device into buffer buf. - * A seek to the start of the device file is done first - * then a read is requested in one go of size bytes. - * - * It is the caller's responsibility to do further op_read_device() - * calls if the number of bytes read is not what is requested - * (where this is applicable). - * - * The number of bytes read is returned, or a negative number - * on failure (in which case errno will be set). If the call is - * interrupted, then errno will be EINTR, and the client should - * arrange for re-starting the read if necessary. - */ -ssize_t op_read_device(fd_t devfd, void * buf, size_t size); - -#ifdef __cplusplus -} -#endif - -#endif /* OP_DEVICEIO_H */ diff --git a/libutil/op_file.c b/libutil/op_file.c deleted file mode 100644 index e3e6cb6..0000000 --- a/libutil/op_file.c +++ /dev/null @@ -1,185 +0,0 @@ -/** - * @file op_file.c - * Useful file management helpers - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#include <sys/stat.h> -#include <unistd.h> -#include <fcntl.h> -#include <dirent.h> -#include <fnmatch.h> -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <string.h> -#include <limits.h> - -#include "op_file.h" -#include "op_libiberty.h" - -int op_file_readable(char const * file) -{ - struct stat st; - return !stat(file, &st) && S_ISREG(st.st_mode) && !access(file, R_OK); -} - - -time_t op_get_mtime(char const * file) -{ - struct stat st; - - if (stat(file, &st)) - return 0; - - return st.st_mtime; -} - - -int create_dir(char const * dir) -{ - if (mkdir(dir, 0755)) { - /* FIXME: Does not verify existing is a dir */ - if (errno == EEXIST) - return 0; - return errno; - } - - return 0; -} - - -int create_path(char const * path) -{ - int ret = 0; - - char * str = xstrdup(path); - - char * pos = str[0] == '/' ? str + 1 : str; - - for ( ; (pos = strchr(pos, '/')) != NULL; ++pos) { - *pos = '\0'; - ret = create_dir(str); - *pos = '/'; - if (ret) - break; - } - - free(str); - return ret; -} - - -inline static int is_dot_or_dotdot(char const * name) -{ - return name[0] == '.' && - (name[1] == '\0' || - (name[1] == '.' && name[2] == '\0')); -} - - -/* If non-null is returned, the caller is responsible for freeing - * the memory allocated for the return value. */ -static char * make_pathname_from_dirent(char const * basedir, - struct dirent * ent, - struct stat * st_buf) -{ - int name_len; - char * name; - name_len = strlen(basedir) + strlen("/") + strlen(ent->d_name) + 1; - name = xmalloc(name_len); - sprintf(name, "%s/%s", basedir, ent->d_name); - if (stat(name, st_buf) != 0) { - free(name); - name = NULL; - } - return name; -} - - -int get_matching_pathnames(void * name_list, get_pathname_callback getpathname, - char const * base_dir, char const * filter, - enum recursion_type recursion) -{ -/* The algorithm below depends on recursion type (of which there are 3) - * and whether the current dirent matches the filter. There are 6 possible - * different behaviors, which is why we define 6 case below in the switch - * statement of the algorithm. Actually, when the recursion type is - * MATCH_DIR_ONLY_RECURSION, the behavior is the same, whether or not the dir - * entry matches the filter. However, the behavior of the recursion types - * NO_RECURSION and MATCH_ANY_ENTRY_RECURSION do depend on the dir entry - * filter match, so for simplicity, we perform this match for all recursion - * types and logically OR the match result with the value of the passed - * recursion_type. - */ -#define NO_MATCH 0 -#define MATCH 1 - - DIR * dir; - struct dirent * ent; - struct stat stat_buffer; - int match; - char * name = NULL; - - if (!(dir = opendir(base_dir))) - return -1; - while ((ent = readdir(dir)) != 0) { - if (is_dot_or_dotdot(ent->d_name)) - continue; - if (fnmatch(filter, ent->d_name, 0) == 0) - match = 1; - else - match = 0; - - switch (recursion | match) { - case NO_RECURSION + NO_MATCH: - case MATCH_ANY_ENTRY_RECURSION + NO_MATCH: - // nothing to do but continue the loop - break; - case NO_RECURSION + MATCH: - getpathname(ent->d_name, name_list); - break; - case MATCH_ANY_ENTRY_RECURSION + MATCH: - name = make_pathname_from_dirent(base_dir, ent, - &stat_buffer); - if (name && S_ISDIR(stat_buffer.st_mode) && - !S_ISLNK(stat_buffer.st_mode)) { - get_matching_pathnames( - name_list, getpathname, - name, filter, recursion); - } else { - getpathname(name, name_list); - } - free(name); - break; - case MATCH_DIR_ONLY_RECURSION + NO_MATCH: - case MATCH_DIR_ONLY_RECURSION + MATCH: - name = make_pathname_from_dirent(base_dir, ent, - &stat_buffer); - if (name && S_ISDIR(stat_buffer.st_mode) && - !S_ISLNK(stat_buffer.st_mode)) { - /* Check if full directory name contains - * match to the filter; if so, add it to - * name_list and quit; else, recurse. - */ - if (!fnmatch(filter, name, 0)) { - getpathname(name, name_list); - } else { - get_matching_pathnames( - name_list, getpathname, - name, filter, recursion); - } - } - free(name); - break; - } - } - closedir(dir); - - return 0; -} diff --git a/libutil/op_file.h b/libutil/op_file.h deleted file mode 100644 index d22862c..0000000 --- a/libutil/op_file.h +++ /dev/null @@ -1,109 +0,0 @@ -/** - * @file op_file.h - * Useful file management helpers - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_FILE_H -#define OP_FILE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> - -/** - * op_file_readable - is a file readable - * @param file file name - * - * Return true if the given file is readable and regular. - * - * Beware of race conditions ! - */ -int op_file_readable(char const * file); - -/** - * op_get_mtime - get mtime of file - * @param file file name - * - * Returns the mtime of the given file or 0 on failure - */ -time_t op_get_mtime(char const * file); - -/** - * create_dir - create a directory - * @param dir the directory name to create - * - * Returns 0 on success. - */ -int create_dir(char const * dir); - - -/** - * create_path - create a path - * @param path the path to create - * - * create directory for each dir components in path - * the last path component is not considered as a directory - * but as a filename - * - * Returns 0 on success. - */ -int create_path(char const * path); - -/** - * Clients of get_matching_pathnames must provide their own implementation - * of get_pathname_callback. - */ -typedef void (*get_pathname_callback)(char const * pathname, void * name_list); - -/* This enum is intended solely for the use of get_matching_pathnames(), - * bit 0 is reserved for internal use..*/ -enum recursion_type { - NO_RECURSION = 2, - MATCH_ANY_ENTRY_RECURSION = 4, - MATCH_DIR_ONLY_RECURSION = 8, -}; -/** - * @param name_list where to store result - * @param get_pathname_callback client-provided callback function - * @param base_dir directory from where lookup starts - * @param filter a pathname filter - * @param recursion recursion_type -- see above enum and following description: - * NO_RECURSION: Find matching files from passed base_dir and call - * get_pathname_callback to add entry to name_list to be returned. - * MATCH_ANY_ENTRY_RECURSION: Starting at base_dir, for each entry in the - * dir that matches the filter: if entry is of type 'dir', recurse; - * else call get_pathname_callback to add entry to name_list to be - * returned. - * MATCH_DIR_ONLY_RECURSION: Starting at base_dir, if an entry in the - * dir is of type 'dir' and its complete pathname contains a match to - * the filter, call get_pathname_callback to add entry to name_list to - * be returned; else recurse. - * - * Returns 0 on success. - * - * Return a list of pathnames under base_dir, filtered by filter and optionally - * looking in sub-directory. See description above of the recursion_type - * parameter for more details. - * NOTE: For C clients: Your implementation of the get_pathname_callback - * function will probably dynamically allocate storage for elements - * added to name_list. If so, remember to free that memory when it's - * no longer needed. - */ -int get_matching_pathnames(void * name_list, get_pathname_callback, - char const * base_dir, char const * filter, - enum recursion_type recursion); - - -#ifdef __cplusplus -} -#endif - -#endif /* OP_FILE_H */ diff --git a/libutil/op_fileio.c b/libutil/op_fileio.c deleted file mode 100644 index 9b3e21d..0000000 --- a/libutil/op_fileio.c +++ /dev/null @@ -1,228 +0,0 @@ -/** - * @file op_fileio.c - * Reading from / writing to files - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#include <unistd.h> - -#include "op_fileio.h" - -#include "op_libiberty.h" - -#include <errno.h> -#include <string.h> -#include <stdlib.h> - -static FILE * op_do_open_file(char const * name, char const * mode, int fatal) -{ - FILE * fp; - - fp = fopen(name, mode); - - if (!fp) { - if (fatal) { - fprintf(stderr,"oprofiled:op_do_open_file: %s: %s", - name, strerror(errno)); - exit(EXIT_FAILURE); - } - } - - return fp; -} - - -FILE * op_try_open_file(char const * name, char const * mode) -{ - return op_do_open_file(name, mode, 0); -} - - -FILE * op_open_file(char const * name, char const * mode) -{ - return op_do_open_file(name, mode, 1); -} - - -void op_close_file(FILE * fp) -{ - if (fclose(fp)) - perror("oprofiled:op_close_file: "); -} - - -void op_write_file(FILE * fp, void const * buf, size_t size) -{ - size_t written; - - if (size == 0) - return; - - written = fwrite(buf, size, 1, fp); - - if (written != 1) { - fprintf(stderr, - "oprofiled:op_write_file: wrote less than expected: %lu bytes.\n", - (unsigned long)size); - exit(EXIT_FAILURE); - } -} - - -void op_write_u8(FILE * fp, u8 val) -{ - op_write_file(fp, &val, sizeof(val)); -} - - -void op_write_u32(FILE * fp, u32 val) -{ - op_write_file(fp, &val, sizeof(val)); -} - - -void op_write_u64(FILE * fp, u64 val) -{ - op_write_file(fp, &val, sizeof(val)); -} - - -u32 op_read_int_from_file(char const * filename, int fatal) -{ - FILE * fp; - u32 value; - - fp = fopen(filename, "r"); - if (fp == NULL) { - if (!fatal) - return (u32)-1; - fprintf(stderr, - "op_read_int_from_file: Failed to open %s, reason %s\n", - filename, strerror(errno)); - exit(EXIT_FAILURE); - } - - if (fscanf(fp, "%u", &value) != 1) { - fclose(fp); - if (!fatal) - return (u32)-1; - fprintf(stderr, - "op_read_int_from_file: Failed to convert contents of file %s to integer\n", - filename); - exit(EXIT_FAILURE); - } - - fclose(fp); - - return value; -} - - -char * op_get_line(FILE * fp) -{ - char * buf; - char * cp; - int c; - size_t max = 512; - - buf = xmalloc(max); - cp = buf; - - while (1) { - switch (c = getc(fp)) { - case EOF: - free(buf); - return NULL; - break; - - case '\n': - case '\0': - *cp = '\0'; - return buf; - break; - - default: - *cp = (char)c; - cp++; - if (((size_t)(cp - buf)) == max) { - buf = xrealloc(buf, max + 128); - cp = buf + max; - max += 128; - } - break; - } - } -} - - -/* FIXME the debug info stuff should be handled by binutils */ -unsigned long -calc_crc32(unsigned long crc, unsigned char * buf, size_t len) -{ - static const unsigned long crc32_table[256] = - { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, - 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, - 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, - 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, - 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, - 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, - 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, - 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, - 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, - 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, - 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, - 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, - 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, - 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, - 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, - 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, - 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, - 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, - 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, - 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, - 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, - 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, - 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, - 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, - 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, - 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, - 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, - 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, - 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, - 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, - 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, - 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, - 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, - 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, - 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, - 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, - 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, - 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, - 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, - 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, - 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, - 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, - 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, - 0x2d02ef8d - }; - unsigned char * end; - - crc = ~crc & 0xffffffff; - for (end = buf + len; buf < end; ++buf) - crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8); - return ~crc & 0xffffffff; -} diff --git a/libutil/op_fileio.h b/libutil/op_fileio.h deleted file mode 100644 index 49b126d..0000000 --- a/libutil/op_fileio.h +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @file op_fileio.h - * Reading from / writing to files - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_FILEIO_H -#define OP_FILEIO_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "op_types.h" - -#include <stdio.h> - -/** - * op_try_open_file - open a file - * @param name file name - * @param mode mode string - * - * Open a file name. - * Returns file handle or %NULL on failure. - */ -FILE * op_try_open_file(char const * name, char const * mode); - -/** - * op_open_file - open a file - * @param name file name - * @param mode mode string - * - * Open a file name. - * Failure to open is fatal. - */ -FILE * op_open_file(char const * name, char const * mode); - -/** - * op_read_int_from_file - parse an ASCII value from a file into an integer - * @param filename name of file to parse integer value from - * @param fatal non-zero if any error must be fatal - * - * Reads an ASCII integer from the given file. If an error occur and fatal is - * zero (u32)-1 is returned else the value read in is returned. - */ -u32 op_read_int_from_file(char const * filename, int fatal); - -/** - * op_close_file - close a file - * @param fp file pointer - * - * Closes a file pointer. A non-fatal - * error message is produced if the - * close fails. - */ -void op_close_file(FILE * fp); - -/** - * op_write_file - write to a file - * @param fp file pointer - * @param buf buffer - * @param size nr. of bytes to write - * - * Write size bytes of buffer buf to a file. - * Failure is fatal. - */ -void op_write_file(FILE * fp, void const * buf, size_t size); - -/** - * op_write_u32 - write four bytes to a file - * @param fp file pointer - * @param val value to write - * - * Write an unsigned four-byte value val to a file. - * Failure is fatal. - * - * No byte-swapping is done. - */ -void op_write_u32(FILE * fp, u32 val); - -/** - * op_write_u64 - write eight bytes to a file - * @param fp file pointer - * @param val value to write - * - * Write an unsigned eight-byte value val to a file. - * Failure is fatal. - * - * No byte-swapping is done. - */ -void op_write_u64(FILE * fp, u64 val); - -/** - * op_write_u8 - write a byte to a file - * @param fp file pointer - * @param val value to write - * - * Write an unsigned byte value val to a file. - * Failure is fatal. - */ -void op_write_u8(FILE * fp, u8 val); - -/** - * op_get_line - read an ASCII line from a file - * @param fp file pointer - * - * Get a line of ASCII text from a file. The file is read - * up to the first '\0' or '\n'. A trailing '\n' is deleted. - * - * Returns the dynamically-allocated string containing - * that line. At the end of a file NULL will be returned. - * be returned. - * - * The string returned must be free()d by the caller. - * - * getline() is not a proper solution to replace this function - */ -char * op_get_line(FILE * fp); - -/** - * calc_crc32 - * @param crc current value - * @param buf pointer to buffer - * @param len - * - * Returns current crc computed from the crc argument and the - * characters in len characters in buf. - */ -unsigned long calc_crc32(unsigned long crc, unsigned char * buf, size_t len); - -#ifdef __cplusplus -} -#endif - -#endif /* OP_FILEIO_H */ diff --git a/libutil/op_get_time.c b/libutil/op_get_time.c deleted file mode 100644 index c094c63..0000000 --- a/libutil/op_get_time.c +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @file op_get_time.c - * Get current time as a string - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#include "op_get_time.h" - -#include <time.h> - -char * op_get_time(void) -{ - time_t t = time(NULL); - - if (t == -1) - return ""; - - return ctime(&t); -} diff --git a/libutil/op_get_time.h b/libutil/op_get_time.h deleted file mode 100644 index 8f96273..0000000 --- a/libutil/op_get_time.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file op_get_time.h - * Get current time as a string - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_GET_TIME_H -#define OP_GET_TIME_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * op_get_time - get current date and time - * - * Returns a string representing the current date - * and time, or an empty string on error. - * - * The string is statically allocated and should not be freed. - */ -char * op_get_time(void); - -#ifdef __cplusplus -} -#endif - -#endif /* OP_GET_TIME_H */ diff --git a/libutil/op_growable_buffer.c b/libutil/op_growable_buffer.c deleted file mode 100644 index d138f36..0000000 --- a/libutil/op_growable_buffer.c +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file op_growable_buffer.c - * a growable buffer implementation - * - * @remark Copyright 2007 OProfile authors - * @remark Read the file COPYING - * - * @author Philippe Elie - */ - -#include "op_growable_buffer.h" -#include "op_libiberty.h" - -#include <string.h> -#include <stdlib.h> - -void init_buffer(struct growable_buffer * b) -{ - b->max_size = 0; - b->size = 0; - b->p = NULL; -} - - -void free_buffer(struct growable_buffer * b) -{ - free(b->p); -} - - -static void grow_buffer(struct growable_buffer * b) -{ - size_t new_size = (b->max_size + b->size) * 2; - b->p = xrealloc(b->p, new_size); - b->max_size = new_size; -} - - -void add_data(struct growable_buffer * b, void const * data, size_t len) -{ - size_t old_size = b->size; - b->size += len; - if (b->size > b->max_size) - grow_buffer(b); - memcpy(b->p + old_size, data, len); -} diff --git a/libutil/op_growable_buffer.h b/libutil/op_growable_buffer.h deleted file mode 100644 index 491969a..0000000 --- a/libutil/op_growable_buffer.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * @file op_growable_buffer.h - * a growable buffer interface - * - * @remark Copyright 2007 OProfile authors - * @remark Read the file COPYING - * - * @author Philippe Elie - */ - -#ifndef OP_GROWABLE_BUFFER_H -#define OP_GROWABLE_BUFFER_H - -#include <stddef.h> - -struct growable_buffer { - void * p; - size_t size; - size_t max_size; -}; - -/** - * init_buffer - initialize an empty buffer - * @param buffer the buffer to initialize - * - * init_buffer do not do any allocation, the first allocation will occur - * when add_data() with a non zero len param will be called. - */ -void init_buffer(struct growable_buffer * buffer); - -/** - * free_buffer - free the memory allocated for this buffer - * @param buffer the buffer to free - */ -void free_buffer(struct growable_buffer * buffer); - -/** - * add_data - add data to this buffer - * @param b the buffer where to add data - * @param data a pointer to the data to add - * @param len number of byte to add to the buffer - */ -void add_data(struct growable_buffer * b, void const * data, size_t len); - -#endif /* !OP_GROWABLE_BUFFER_H */ diff --git a/libutil/op_libiberty.c b/libutil/op_libiberty.c deleted file mode 100644 index 0cf45d3..0000000 --- a/libutil/op_libiberty.c +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file op_libiberty.c - * Wrapper for libiberty - always use this instead of - * libiberty.h - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#include <string.h> - -#include "op_libiberty.h" - -#ifndef HAVE_XCALLOC -/* some system have a valid libiberty without xcalloc */ -void * xcalloc(size_t n_elem, size_t sz) -{ - void * ptr = xmalloc(n_elem * sz); - - memset(ptr, '\0', n_elem * sz); - - return ptr; -} -#endif - -#ifndef HAVE_XMEMDUP -void * xmemdup (void const * input, size_t copy_size, size_t alloc_size) -{ - void * output = xcalloc(1, alloc_size); - - memcpy(output, input, copy_size); - - return output; -} -#endif diff --git a/libutil/op_libiberty.h b/libutil/op_libiberty.h deleted file mode 100644 index ea02a50..0000000 --- a/libutil/op_libiberty.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @file op_libiberty.h - * Wrapper for libiberty - always use this instead of - * libiberty.h - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_LIBIBERTY_H -#define OP_LIBIBERTY_H - -#include <stddef.h> - -#include "config.h" - -#ifdef MALLOC_ATTRIBUTE_OK -#define OP_ATTRIB_MALLOC __attribute__((malloc)) -#else -#define OP_ATTRIB_MALLOC -#endif - -#ifdef HAVE_LIBIBERTY_H -#include <libiberty.h> -#else - -#ifdef __cplusplus -extern "C" { -#endif - -/* some system have a libiberty.a but no libiberty.h so we must provide - * ourself the missing proto */ -#ifndef HAVE_LIBIBERTY_H - -/* Set the program name used by xmalloc. */ -void xmalloc_set_program_name(char const *); - -/* Allocate memory without fail. If malloc fails, this will print a - message to stderr (using the name set by xmalloc_set_program_name, - if any) and then call xexit. */ -void * xmalloc(size_t) OP_ATTRIB_MALLOC; - -/* Reallocate memory without fail. This works like xmalloc. Note, - realloc type functions are not suitable for attribute malloc since - they may return the same address across multiple calls. */ -void * xrealloc(void *, size_t); - -/* Allocate memory without fail and set it to zero. This works like xmalloc */ -void * xcalloc(size_t, size_t) OP_ATTRIB_MALLOC; - -/* Copy a string into a memory buffer without fail. */ -char * xstrdup(char const *) OP_ATTRIB_MALLOC; - -/** - * Duplicates a region of memory without fail. First, alloc_size bytes - * are allocated, then copy_size bytes from input are copied into - * it, and the new memory is returned. If fewer bytes are copied than were - * allocated, the remaining memory is zeroed. - */ -void * xmemdup(void const *, size_t, size_t) OP_ATTRIB_MALLOC; - -#endif /* !HAVE_LIBIBERTY_H */ - -#ifdef ANDROID -#define xmalloc(s) malloc(s) -#define xrealloc(p,s) realloc(p,s) -#define xstrdup(str) strdup(str) -#define xmalloc_set_program_name(n) -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* !HAVE_LIBIBERTY_H */ - -#endif /* OP_LIBIBERTY_H */ diff --git a/libutil/op_list.h b/libutil/op_list.h deleted file mode 100644 index ed0cd8a..0000000 --- a/libutil/op_list.h +++ /dev/null @@ -1,177 +0,0 @@ -/** - * @file op_list.h - * Kernel-style lists - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author Linux kernel authors - */ - -#ifndef OP_LIST_H -#define OP_LIST_H - -/* - * Simple doubly linked list implementation. - * - * Some of the internal functions ("__xxx") are useful when - * manipulating whole lists rather than single entries, as - * sometimes we already know the next/prev entries and we can - * generate better code by using them directly rather than - * using the generic single-entry routines. - */ - -struct list_head { - struct list_head * next, * prev; -}; - -/** - * list_init - init a new entry - * @param ptr the list to init - * - * Init a list head to create an empty list from it - */ -static __inline__ void list_init(struct list_head * ptr) -{ - ptr->next = ptr; - ptr->prev = ptr; -} - -/* - * Insert a new entry between two known consecutive entries. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static __inline__ void __list_add(struct list_head * new_entry, - struct list_head * prev, - struct list_head * next) -{ - next->prev = new_entry; - new_entry->next = next; - new_entry->prev = prev; - prev->next = new_entry; -} - -/** - * list_add - add a new entry - * @param new new entry to be added - * @param head list head to add it after - * - * Insert a new entry after the specified head. - * This is good for implementing stacks. - */ -static __inline__ void list_add(struct list_head * new_entry, struct list_head * head) -{ - __list_add(new_entry, head, head->next); -} - -/** - * list_add_tail - add a new entry - * @param new new entry to be added - * @param head list head to add it before - * - * Insert a new entry before the specified head. - * This is useful for implementing queues. - */ -static __inline__ void list_add_tail(struct list_head * new_entry, struct list_head * head) -{ - __list_add(new_entry, head->prev, head); -} - -/* - * Delete a list entry by making the prev/next entries - * point to each other. - * - * This is only for internal list manipulation where we know - * the prev/next entries already! - */ -static __inline__ void __list_del(struct list_head * prev, - struct list_head * next) -{ - next->prev = prev; - prev->next = next; -} - -/** - * list_del - deletes entry from list. - * @param entry the element to delete from the list. - * Note: list_empty on entry does not return true after this, the entry is in an undefined state. - */ -static __inline__ void list_del(struct list_head * entry) -{ - __list_del(entry->prev, entry->next); -} - -/** - * list_del_init - deletes entry from list and reinitialize it. - * @param entry the element to delete from the list. - */ -static __inline__ void list_del_init(struct list_head * entry) -{ - __list_del(entry->prev, entry->next); - list_init(entry); -} - -/** - * list_empty - tests whether a list is empty - * @param head the list to test. - */ -static __inline__ int list_empty(struct list_head const * head) -{ - return head->next == head; -} - -/** - * list_splice - join two lists - * @param list the new list to add. - * @param head the place to add it in the first list. - */ -static __inline__ void list_splice(struct list_head * list, struct list_head * head) -{ - struct list_head * first = list->next; - - if (first != list) { - struct list_head * last = list->prev; - struct list_head * at = head->next; - - first->prev = head; - head->next = first; - - last->next = at; - at->prev = last; - } -} - -/** - * list_entry - get the struct for this entry - * @param ptr the &struct list_head pointer. - * @param type the type of the struct this is embedded in. - * @param member the name of the list_struct within the struct. - */ -#define list_entry(ptr, type, member) \ - ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member))) - -/** - * list_for_each - iterate over a list - * @param pos the &struct list_head to use as a loop counter. - * @param head the head for your list. - */ -#define list_for_each(pos, head) \ - for (pos = (head)->next; pos != (head); pos = pos->next) - -/** - * list_for_each_safe - iterate over a list safe against removal of list entry - * @param pos the &struct list_head to use as a loop counter. - * @param n another &struct list_head to use as temporary storage - * @param head the head for your list. - */ -#define list_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; pos != (head); \ - pos = n, n = pos->next) - -#define LIST_HEAD_INIT(name) { &(name), &(name) } - -#define LIST_HEAD(name) struct list_head name = LIST_HEAD_INIT(name) - -#endif /* OP_LIST_H */ diff --git a/libutil/op_lockfile.c b/libutil/op_lockfile.c deleted file mode 100644 index 26e3249..0000000 --- a/libutil/op_lockfile.c +++ /dev/null @@ -1,69 +0,0 @@ -/** - * @file op_lockfile.c - * PID-based lockfile management - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#include "op_lockfile.h" -#include "op_file.h" - -#include <errno.h> - -#include <sys/types.h> -#include <stdio.h> -#include <signal.h> -#include <unistd.h> - -static pid_t op_read_lock_file(char const * file) -{ - FILE * fp; - pid_t value; - - fp = fopen(file, "r"); - if (fp == NULL) - return 0; - - if (fscanf(fp, "%d", &value) != 1) { - fclose(fp); - return 0; - } - - fclose(fp); - - return value; -} - - -int op_write_lock_file(char const * file) -{ - FILE * fp; - - if (op_file_readable(file)) { - pid_t pid = op_read_lock_file(file); - - /* FIXME: ESRCH vs. EPERM */ - if (kill(pid, 0)) { - int err = unlink(file); - fprintf(stderr, "Removing stale lock file %s\n", - file); - if (err) - return err; - } else { - return EEXIST; - } - } - - fp = fopen(file, "w"); - if (!fp) - return errno; - - fprintf(fp, "%d", getpid()); - fclose(fp); - - return 0; -} diff --git a/libutil/op_lockfile.h b/libutil/op_lockfile.h deleted file mode 100644 index fcc269c..0000000 --- a/libutil/op_lockfile.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file op_lockfile.h - * PID-based lockfile management - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_LOCKFILE_H -#define OP_LOCKFILE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <sys/types.h> - -/** - * op_write_lock_file - write a lock file - * \return errno on failure, or 0 on success - * - * Write the pid into the given lock file. Stale - * lock files are detected and reset. - */ -int op_write_lock_file(char const * file); - -#ifdef __cplusplus -} -#endif - -#endif /* OP_LOCKFILE_H */ diff --git a/libutil/op_popt.c b/libutil/op_popt.c deleted file mode 100644 index de96364..0000000 --- a/libutil/op_popt.c +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file op_popt.c - * Wrapper for libpopt - always use this rather - * than popt.h - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#include <stdlib.h> -#include "op_libiberty.h" -#include "op_popt.h" - -poptContext op_poptGetContext(char const * name, - int argc, char const ** argv, - struct poptOption const * options, int flags) -{ - poptContext optcon; - int c; - - xmalloc_set_program_name(argv[0]); - -#ifdef CONST_POPT - optcon = poptGetContext(name, argc, argv, options, flags); -#else - optcon = poptGetContext((char *)name, argc, (char **)argv, options, flags); -#endif - - c = poptGetNextOpt(optcon); - - if (c < -1) { - fprintf(stderr, "%s: %s: %s\n", argv[0], - poptBadOption(optcon, POPT_BADOPTION_NOALIAS), - poptStrerror(c)); - poptPrintHelp(optcon, stderr, 0); - exit(EXIT_FAILURE); - } - - return optcon; -} diff --git a/libutil/op_popt.h b/libutil/op_popt.h deleted file mode 100644 index c3dfa6c..0000000 --- a/libutil/op_popt.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * @file op_popt.h - * Wrapper for libpopt - always use this rather - * than popt.h - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_POPT_H -#define OP_POPT_H - -#include <popt.h> - -// not in some versions of popt.h -#ifndef POPT_TABLEEND -#define POPT_TABLEEND { NULL, '\0', 0, 0, 0, NULL, NULL } -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * op_poptGetContext - wrapper for popt - * - * Use this instead of poptGetContext to cope with - * different popt versions. This also handle unrecognized - * options. All error are fatal. - */ -poptContext op_poptGetContext(char const * name, - int argc, char const ** argv, - struct poptOption const * options, int flags); - -#ifdef __cplusplus -} -#endif - -#endif /* OP_POPT_H */ diff --git a/libutil/op_string.c b/libutil/op_string.c deleted file mode 100644 index d440299..0000000 --- a/libutil/op_string.c +++ /dev/null @@ -1,62 +0,0 @@ -/** - * @file op_string.c - * general purpose C string handling implementation. - * - * @remark Copyright 2003 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#include <string.h> -#include "op_libiberty.h" - - -char * op_xstrndup(char const * s, size_t len) -{ - return xmemdup(s, len, len + 1); -} - - -size_t op_hash_string(char const * str) -{ - size_t hash = 0; - for (; *str; ++str) - hash ^= (hash << 16) ^ (hash >> 8) ^ *str; - return hash; -} - - -int strisprefix(char const * str, char const * prefix) -{ - return strstr(str, prefix) == str; -} - - -char const * skip_ws(char const * c) -{ - while (*c == ' ' || *c == '\t' || *c == '\n') - ++c; - return c; -} - - -char const * skip_nonws(char const * c) -{ - while (*c && *c != ' ' && *c != '\t' && *c != '\n') - ++c; - return c; -} - - -int empty_line(char const * c) -{ - return !*skip_ws(c); -} - - -int comment_line(char const * c) -{ - return *skip_ws(c) == '#'; -} diff --git a/libutil/op_string.h b/libutil/op_string.h deleted file mode 100644 index 993fa6f..0000000 --- a/libutil/op_string.h +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @file op_string.h - * general purpose C string handling declarations. - * - * @remark Copyright 2003 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_STRING_H -#define OP_STRING_H - -#include <string.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @param s: input string - * @param len: len char to copy - * - * Allocate and copy len character from s to a newly allocated buffer then - * append a '\0' terminator. Return the newly allocated string - */ -char * op_xstrndup(char const * s, size_t len); - -/** - * @param s: string to hash - * - * Generate a hash code from a string - */ -size_t op_hash_string(char const * s); - -/** - * @param str: string to test - * @param prefix: prefix string - * - * return non zero if prefix parameters is a prefix of str - */ -int strisprefix(char const * str, char const * prefix); - -/** - * @param c: input string - * - * return a pointer to the first location in c which is not a blank space - * where blank space are in " \t\n" - */ -char const * skip_ws(char const * c); - -/** - * @param c: input string - * - * return a pointer to the first location in c which is a blank space - * where blank space are in " \t\n" - */ -char const * skip_nonws(char const * c); - -/** - * @param c: input string - * - * return non zero if c string contains only blank space - * where blank space are in " \t\n" - */ -int empty_line(char const * c); - -/** - * @param c: input string - * - * return non zero if c string is a comment. Comment are lines with optional - * blank space at left then a '#' character. Blank space are in " \t\n" - */ -int comment_line(char const * c); - -#ifdef __cplusplus -} -#endif - -#endif /* !OP_STRING_H */ diff --git a/libutil/op_types.h b/libutil/op_types.h deleted file mode 100644 index c025b23..0000000 --- a/libutil/op_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @file op_types.h - * General-utility types - * - * @remark Copyright 2002 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_TYPES_H -#define OP_TYPES_H - -#ifndef __KERNEL__ - -#include <sys/types.h> - -/*@{\name miscellaneous types */ -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef unsigned long long u64; -typedef int fd_t; -/*@}*/ - -/** generic type for holding addresses */ -typedef unsigned long long vma_t; - -/** generic type to hold a sample count in pp tools */ -typedef u64 count_type; - -#else -#include <linux/types.h> -#endif - -#endif /* OP_TYPES_H */ diff --git a/libutil/op_version.c b/libutil/op_version.c deleted file mode 100644 index 99a844e..0000000 --- a/libutil/op_version.c +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @file op_version.c - * output version string - * - * @remark Copyright 2003 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#include <stdio.h> -#include <stdlib.h> - -#include "op_version.h" -#include "config.h" - -void show_version(char const * app_name) -{ - /* Do not change the version format: it is documented in html doc */ - printf("%s: " PACKAGE " " VERSION " compiled on " - __DATE__ " " __TIME__ "\n", app_name); - exit(EXIT_SUCCESS); -} diff --git a/libutil/op_version.h b/libutil/op_version.h deleted file mode 100644 index 43a8365..0000000 --- a/libutil/op_version.h +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @file op_version.h - * output version string - * - * @remark Copyright 2003 OProfile authors - * @remark Read the file COPYING - * - * @author John Levon - * @author Philippe Elie - */ - -#ifndef OP_VERSION_H -#define OP_VERSION_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** output the version string */ -void show_version(char const * app_name); - -#ifdef __cplusplus -} -#endif - -#endif /* !OP_VERSION_H */ |