github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/include/jit/jit-util.h (about) 1 /* 2 * jit-util.h - Utility functions. 3 * 4 * Copyright (C) 2004 Southern Storm Software, Pty Ltd. 5 * 6 * The libjit library is free software: you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public License 8 * as published by the Free Software Foundation, either version 2.1 of 9 * the License, or (at your option) any later version. 10 * 11 * The libjit library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with the libjit library. If not, see 18 * <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef _JIT_UTIL_H 22 #define _JIT_UTIL_H 23 24 #include <jit/jit-common.h> 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 /* 31 * Memory allocation routines. 32 */ 33 void *jit_malloc(unsigned int size) JIT_NOTHROW; 34 void *jit_calloc(unsigned int num, unsigned int size) JIT_NOTHROW; 35 void *jit_realloc(void *ptr, unsigned int size) JIT_NOTHROW; 36 void jit_free(void *ptr) JIT_NOTHROW; 37 38 #define jit_new(type) ((type *)jit_malloc(sizeof(type))) 39 #define jit_cnew(type) ((type *)jit_calloc(1, sizeof(type))) 40 41 /* 42 * Memory set/copy/compare routines. 43 */ 44 void *jit_memset(void *dest, int ch, unsigned int len) JIT_NOTHROW; 45 void *jit_memcpy(void *dest, const void *src, unsigned int len) JIT_NOTHROW; 46 void *jit_memmove(void *dest, const void *src, unsigned int len) JIT_NOTHROW; 47 int jit_memcmp(const void *s1, const void *s2, unsigned int len) JIT_NOTHROW; 48 void *jit_memchr(const void *str, int ch, unsigned int len) JIT_NOTHROW; 49 50 /* 51 * String routines. 52 */ 53 unsigned int jit_strlen(const char *str) JIT_NOTHROW; 54 char *jit_strcpy(char *dest, const char *src) JIT_NOTHROW; 55 char *jit_strcat(char *dest, const char *src) JIT_NOTHROW; 56 char *jit_strncpy(char *dest, const char *src, unsigned int len) JIT_NOTHROW; 57 char *jit_strdup(const char *str) JIT_NOTHROW; 58 char *jit_strndup(const char *str, unsigned int len) JIT_NOTHROW; 59 int jit_strcmp(const char *str1, const char *str2) JIT_NOTHROW; 60 int jit_strncmp 61 (const char *str1, const char *str2, unsigned int len) JIT_NOTHROW; 62 int jit_stricmp(const char *str1, const char *str2) JIT_NOTHROW; 63 int jit_strnicmp 64 (const char *str1, const char *str2, unsigned int len) JIT_NOTHROW; 65 char *jit_strchr(const char *str, int ch) JIT_NOTHROW; 66 char *jit_strrchr(const char *str, int ch) JIT_NOTHROW; 67 int jit_sprintf(char *str, const char *format, ...) JIT_NOTHROW; 68 int jit_snprintf 69 (char *str, unsigned int len, const char *format, ...) JIT_NOTHROW; 70 71 #ifdef __cplusplus 72 }; 73 #endif 74 75 #endif /* _JIT_UTIL_H */