Fix pthread init and null for C++
This commit is contained in:
@@ -9,3 +9,10 @@
|
||||
include_guard = "_RELIBC_BITS_NULL_T_H"
|
||||
language = "C"
|
||||
no_includes = true
|
||||
after_includes = """
|
||||
#ifdef __cplusplus
|
||||
#define NULL nullptr
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
"""
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
use crate::platform::types::c_long;
|
||||
|
||||
/// Null pointer constant.
|
||||
pub const NULL: c_long = 0;
|
||||
// NULL is defined in cbindgen
|
||||
|
||||
@@ -6,10 +6,10 @@ no_includes = true
|
||||
cpp_compat = true
|
||||
# TODO: Any better way to implement pthread_cleanup_push/pthread_cleanup_pop?
|
||||
after_includes = """
|
||||
#define PTHREAD_COND_INITIALIZER ((pthread_cond_t){0})
|
||||
#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t){0})
|
||||
#define PTHREAD_COND_INITIALIZER {0}
|
||||
#define PTHREAD_MUTEX_INITIALIZER {0}
|
||||
#define PTHREAD_RWLOCK_INITIALIZER {0}
|
||||
#define PTHREAD_ONCE_INIT ((pthread_once_t){0})
|
||||
#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t){0})
|
||||
|
||||
#define pthread_cleanup_push(ROUTINE, ARG) do { \\
|
||||
struct { \\
|
||||
|
||||
@@ -15,7 +15,9 @@ after_includes = """
|
||||
#include <bits/timespec.h> // for timespec
|
||||
#include <bits/pthread.h> // for pthread-related types
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define thread_local _Thread_local
|
||||
#endif
|
||||
#define ONCE_FLAG_INIT PTHREAD_ONCE_INIT // once_flag == pthread_once_t
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user