This change extracts the `weak*`-related parts of #303 as a separate PR.
Note that this is slightly strange in that it uses some top-half MUSL
headers in the bottom-half code, but discussion around this led me to
believe that the advantages of, e.g., `LOCK` made this worthwhile.
Beyond just changing uses of `weak` to `__weak__`, we also MUSL's `weak`
and `weak_alias` macros in a few more places.
startup_files $(LIBC_BOTTOM_HALF_ALL_OBJS): CFLAGS += \
-I$(LIBC_BOTTOM_HALF_HEADERS_PRIVATE) \
-I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC_INC) \
- -I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC)
+ -I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC) \
+ -I$(LIBC_TOP_HALF_MUSL_SRC_DIR)/include \
+ -I$(LIBC_TOP_HALF_MUSL_SRC_DIR)/internal
$(LIBC_TOP_HALF_ALL_OBJS) $(MUSL_PRINTSCAN_LONG_DOUBLE_OBJS) $(MUSL_PRINTSCAN_NO_FLOATING_POINT_OBJS) $(LIBWASI_EMULATED_SIGNAL_MUSL_OBJS): CFLAGS += \
-I$(LIBC_TOP_HALF_MUSL_SRC_DIR)/include \
*tp = timestamp_to_timespec(ts);
return 0;
}
-extern __typeof(__clock_gettime) clock_gettime __attribute__((weak, alias("__clock_gettime")));
+weak_alias(__clock_gettime, clock_gettime);
return new_offset;
}
-extern __typeof(__lseek) lseek __attribute__((weak, alias("__lseek")));
+weak_alias(__lseek, lseek);
char **relative,
size_t *relative_len,
int can_realloc
-) __attribute__((weak));
+) __attribute__((__weak__));
#ifdef __cplusplus
}
// If the user's `main` function expects arguments, the compiler will rename
// it to `__main_argc_argv`, and this version will get linked in, which
// initializes the argument data and calls `__main_argc_argv`.
-__attribute__((weak, nodebug))
+__attribute__((__weak__, nodebug))
int __main_void(void) {
__wasi_errno_t err;
/// Statically-initialize it to an invalid pointer value so that we can
/// detect if it's been explicitly initialized (we can't use `NULL` because
/// `clearenv` sets it to NULL.
-char **__wasilibc_environ __attribute__((weak)) = (char **)-1;
+char **__wasilibc_environ weak = (char **)-1;
// See the comments in libc-environ.h.
void __wasilibc_ensure_environ(void) {
}
// See the comments in libc-environ.h.
-__attribute__((weak))
+weak
void __wasilibc_maybe_reinitialize_environ_eagerly(void) {
// This version does nothing. It may be overridden by a version which does
// something if `environ` is used.
// `__wasilibc_environ`, which is initialized with a constructor function, so
// that it's initialized whenever user code might want to access it.
char **__wasilibc_environ;
-extern __typeof(__wasilibc_environ) _environ
- __attribute__((weak, alias("__wasilibc_environ")));
-extern __typeof(__wasilibc_environ) environ
- __attribute__((weak, alias("__wasilibc_environ")));
+weak_alias(__wasilibc_environ, _environ);
+weak_alias(__wasilibc_environ, environ);
// We define this function here in the same source file as
// `__wasilibc_environ`, so that this function is called in iff environment
return 0;
}
-extern __typeof(__getentropy) getentropy __attribute__((weak, alias("__getentropy")));
+weak_alias(__getentropy, getentropy);