Skip to content

Commit

Permalink
Make frozen's symbols weak
Browse files Browse the repository at this point in the history
So that it can be amalgamated in multiple modules which are used
together.

PUBLISHED_FROM=6fda7ee4fda4d613babbf2d2c78b1032ecf03cfa
  • Loading branch information
dimonomid authored and cesantabot committed Jan 13, 2017
1 parent 46dbb25 commit 69d64af
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions frozen.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
#include <stdlib.h>
#include <string.h>

#if !defined(WEAK)
#if (defined(__GNUC__) || defined(__TI_COMPILER_VERSION__)) && !defined(_WIN32)
#define WEAK __attribute__((weak))
#else
#define WEAK
#endif
#endif

#ifdef _WIN32
#define snprintf cs_win_snprintf
#define vsnprintf cs_win_vsnprintf
Expand Down Expand Up @@ -446,6 +454,7 @@ static int json_encode_string(struct json_out *out, const char *p, size_t len) {
return n;
}

int json_printer_buf(struct json_out *out, const char *buf, size_t len) WEAK;
int json_printer_buf(struct json_out *out, const char *buf, size_t len) {
size_t avail = out->u.buf.size - out->u.buf.len;
size_t n = len < avail ? len : avail;
Expand All @@ -459,6 +468,7 @@ int json_printer_buf(struct json_out *out, const char *buf, size_t len) {
return len;
}

int json_printer_file(struct json_out *out, const char *buf, size_t len) WEAK;
int json_printer_file(struct json_out *out, const char *buf, size_t len) {
return fwrite(buf, 1, len, out->u.fp);
}
Expand Down Expand Up @@ -532,6 +542,7 @@ static int b64dec(const char *src, int n, char *dst) {
return len;
}

int json_vprintf(struct json_out *out, const char *fmt, va_list xap) WEAK;
int json_vprintf(struct json_out *out, const char *fmt, va_list xap) {
int len = 0;
const char *quote = "\"", *null = "null";
Expand Down Expand Up @@ -697,6 +708,7 @@ int json_vprintf(struct json_out *out, const char *fmt, va_list xap) {
return len;
}

int json_printf(struct json_out *out, const char *fmt, ...) WEAK;
int json_printf(struct json_out *out, const char *fmt, ...) {
int n;
va_list ap;
Expand All @@ -706,6 +718,7 @@ int json_printf(struct json_out *out, const char *fmt, ...) {
return n;
}

int json_printf_array(struct json_out *out, va_list *ap) WEAK;
int json_printf_array(struct json_out *out, va_list *ap) {
int len = 0;
char *arr = va_arg(*ap, char *);
Expand All @@ -732,6 +745,7 @@ int json_printf_array(struct json_out *out, va_list *ap) {
}

#ifdef _WIN32
int cs_win_vsnprintf(char *str, size_t size, const char *format, va_list ap) WEAK;
int cs_win_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
int res = _vsnprintf(str, size, format, ap);
va_end(ap);
Expand All @@ -741,6 +755,7 @@ int cs_win_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
return res;
}

int cs_win_snprintf(char *str, size_t size, const char *format, ...) WEAK;
int cs_win_snprintf(char *str, size_t size, const char *format, ...) {
int res;
va_list ap;
Expand All @@ -751,6 +766,8 @@ int cs_win_snprintf(char *str, size_t size, const char *format, ...) {
}
#endif /* _WIN32 */

int json_walk(const char *json_string, int json_string_length,
json_walk_callback_t callback, void *callback_data) WEAK;
int json_walk(const char *json_string, int json_string_length,
json_walk_callback_t callback, void *callback_data) {
struct frozen frozen;
Expand Down Expand Up @@ -784,6 +801,8 @@ static void json_scanf_array_elem_cb(void *callback_data, const char *name,
}
}

int json_scanf_array_elem(const char *s, int len, const char *path, int idx,
struct json_token *token) WEAK;
int json_scanf_array_elem(const char *s, int len, const char *path, int idx,
struct json_token *token) {
struct scan_array_info info;
Expand All @@ -803,6 +822,7 @@ struct json_scanf_info {
int type;
};

int json_unescape(const char *src, int slen, char *dst, int dlen) WEAK;
int json_unescape(const char *src, int slen, char *dst, int dlen) {
char *send = (char *) src + slen, *dend = dst + dlen, *orig_dst = dst, *p;
const char *esc1 = "\"\\/bfnrt", *esc2 = "\"\\/\b\f\n\r\t";
Expand Down Expand Up @@ -908,6 +928,7 @@ static void json_scanf_cb(void *callback_data, const char *name,
}
}

int json_vscanf(const char *s, int len, const char *fmt, va_list ap) WEAK;
int json_vscanf(const char *s, int len, const char *fmt, va_list ap) {
char path[JSON_MAX_PATH_LEN] = "", fmtbuf[20];
int i = 0;
Expand Down Expand Up @@ -958,6 +979,7 @@ int json_vscanf(const char *s, int len, const char *fmt, va_list ap) {
return info.num_conversions;
}

int json_scanf(const char *str, int len, const char *fmt, ...) WEAK;
int json_scanf(const char *str, int len, const char *fmt, ...) {
int result;
va_list ap;
Expand Down

0 comments on commit 69d64af

Please sign in to comment.