mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
more changes to make the C runtime compilable with MSVC
This commit is contained in:
@@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
set(GNU_LIGHTNING_ARCH "i386" CACHE STRING "Target architecture for GNU Lightning JIT")
|
||||
#set(ADD_CFLAGS "-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-value" CACHE STRING "Additional C compiler options")
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ${ADD_CFLAGS}")
|
||||
|
||||
|
||||
@@ -18,7 +18,13 @@
|
||||
#define GU_API ERROR_NOT_COMPILING_LIBGU
|
||||
#endif
|
||||
|
||||
#define GU_INTERNAL_DECL
|
||||
#define GU_INTERNAL
|
||||
|
||||
#define restrict __restrict
|
||||
|
||||
#else
|
||||
|
||||
#define GU_API_DECL
|
||||
#define GU_API
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ gu_hash_byte(GuHash h, uint8_t u)
|
||||
}
|
||||
|
||||
|
||||
GU_API GuHash
|
||||
GU_API_DECL GuHash
|
||||
gu_hash_bytes(GuHash h, const uint8_t* buf, size_t len);
|
||||
|
||||
typedef const struct GuHasher GuHasher;
|
||||
|
||||
@@ -44,7 +44,7 @@ gu_in_bytes(GuIn* in, uint8_t* buf, size_t sz, GuExn* err)
|
||||
ptrdiff_t curr = in->buf_curr;
|
||||
ptrdiff_t new_curr = curr + (ptrdiff_t) sz;
|
||||
if (GU_UNLIKELY(new_curr > 0)) {
|
||||
extern void gu_in_bytes_(GuIn* in, uint8_t* buf, size_t sz,
|
||||
GU_API_DECL void gu_in_bytes_(GuIn* in, uint8_t* buf, size_t sz,
|
||||
GuExn* err);
|
||||
gu_in_bytes_(in, buf, sz, err);
|
||||
return;
|
||||
@@ -73,7 +73,7 @@ inline uint8_t
|
||||
gu_in_u8(GuIn* restrict in, GuExn* err)
|
||||
{
|
||||
if (GU_UNLIKELY(in->buf_curr == 0)) {
|
||||
extern uint8_t gu_in_u8_(GuIn* restrict in, GuExn* err);
|
||||
GU_API_DECL uint8_t gu_in_u8_(GuIn* restrict in, GuExn* err);
|
||||
return gu_in_u8_(in, err);
|
||||
}
|
||||
return in->buf_end[in->buf_curr++];
|
||||
|
||||
@@ -21,7 +21,7 @@ typedef struct GuPool GuPool;
|
||||
|
||||
|
||||
/// Create a new memory pool.
|
||||
GU_ONLY GuPool*
|
||||
GU_API_DECL GuPool*
|
||||
gu_new_pool(void);
|
||||
|
||||
/**<
|
||||
|
||||
@@ -101,7 +101,7 @@ inline void
|
||||
gu_out_u8(GuOut* restrict out, uint8_t u, GuExn* err)
|
||||
{
|
||||
if (GU_UNLIKELY(!gu_out_try_u8_(out, u))) {
|
||||
extern void gu_out_u8_(GuOut* restrict out, uint8_t u,
|
||||
GU_API_DECL void gu_out_u8_(GuOut* restrict out, uint8_t u,
|
||||
GuExn* err);
|
||||
gu_out_u8_(out, u, err);
|
||||
}
|
||||
|
||||
@@ -15,28 +15,28 @@ typedef struct {
|
||||
GuFinalizer fin;
|
||||
} GuBuf;
|
||||
|
||||
GuSeq*
|
||||
GU_API_DECL GuSeq*
|
||||
gu_empty_seq();
|
||||
|
||||
GuSeq*
|
||||
GU_API_DECL GuSeq*
|
||||
gu_make_seq(size_t elem_size, size_t len, GuPool* pool);
|
||||
|
||||
#define gu_new_seq(T, N, POOL) \
|
||||
gu_make_seq(sizeof(T), (N), (POOL))
|
||||
|
||||
GuSeq*
|
||||
GU_API_DECL GuSeq*
|
||||
gu_alloc_seq_(size_t elem_size, size_t length);
|
||||
|
||||
#define gu_alloc_seq(T, N) \
|
||||
gu_alloc_seq_(sizeof(T), (N))
|
||||
|
||||
GuSeq*
|
||||
GU_API_DECL GuSeq*
|
||||
gu_realloc_seq_(GuSeq* seq, size_t elem_size, size_t length);
|
||||
|
||||
#define gu_realloc_seq(S, T, N) \
|
||||
gu_realloc_seq_(S, sizeof(T), (N))
|
||||
|
||||
void
|
||||
GU_API_DECL void
|
||||
gu_seq_free(GuSeq* seq);
|
||||
|
||||
inline size_t
|
||||
@@ -63,7 +63,7 @@ gu_seq_data(GuSeq* seq)
|
||||
GU_END
|
||||
|
||||
|
||||
GuBuf*
|
||||
GU_API_DECL GuBuf*
|
||||
gu_make_buf(size_t elem_size, GuPool* pool);
|
||||
|
||||
#define gu_new_buf(T, POOL) \
|
||||
@@ -104,10 +104,10 @@ gu_buf_data_seq(GuBuf* buf)
|
||||
(*gu_buf_index(BUF, T, I) = (V)); \
|
||||
GU_END
|
||||
|
||||
void
|
||||
GU_API_DECL void
|
||||
gu_buf_push_n(GuBuf* buf, const void* elems, size_t n_elems);
|
||||
|
||||
void*
|
||||
GU_API_DECL void*
|
||||
gu_buf_extend_n(GuBuf* buf, size_t n_elems);
|
||||
|
||||
inline void*
|
||||
@@ -121,7 +121,7 @@ gu_buf_extend(GuBuf* buf)
|
||||
((*(T*)gu_buf_extend(BUF)) = (VAL)); \
|
||||
GU_END
|
||||
|
||||
void
|
||||
GU_API_DECL void
|
||||
gu_buf_pop_n(GuBuf* buf, size_t n_elems, void* data_out);
|
||||
|
||||
#define gu_buf_get_last(BUF, T) \
|
||||
@@ -130,7 +130,7 @@ gu_buf_pop_n(GuBuf* buf, size_t n_elems, void* data_out);
|
||||
#define gu_buf_index_last(BUF, T) \
|
||||
(&((T*)gu_buf_data(BUF))[(BUF)->seq->len-1])
|
||||
|
||||
const void*
|
||||
GU_API_DECL const void*
|
||||
gu_buf_trim_n(GuBuf* buf, size_t n_elems);
|
||||
|
||||
inline const void*
|
||||
@@ -139,7 +139,7 @@ gu_buf_trim(GuBuf* buf)
|
||||
return gu_buf_trim_n(buf, 1);
|
||||
}
|
||||
|
||||
void*
|
||||
GU_API_DECL void*
|
||||
gu_buf_insert(GuBuf* buf, size_t n_index);
|
||||
|
||||
inline void
|
||||
@@ -151,40 +151,40 @@ gu_buf_flush(GuBuf* buf)
|
||||
#define gu_buf_pop(BUF, T) \
|
||||
(*(T*)gu_buf_trim(BUF))
|
||||
|
||||
void
|
||||
GU_API_DECL void
|
||||
gu_buf_sort(GuBuf *buf, GuOrder *order);
|
||||
|
||||
#define gu_seq_binsearch(S, O, T, V) \
|
||||
((T*) gu_seq_binsearch_(S, O, sizeof(T), V))
|
||||
|
||||
void*
|
||||
GU_API_DECL void*
|
||||
gu_seq_binsearch_(GuSeq *seq, GuOrder *order, size_t elem_size, const void *key);
|
||||
|
||||
#define gu_seq_binsearch_index(S, O, T, V, PI) \
|
||||
gu_seq_binsearch_index_(S, O, sizeof(T), V, PI)
|
||||
|
||||
bool
|
||||
GU_API_DECL bool
|
||||
gu_seq_binsearch_index_(GuSeq *seq, GuOrder *order, size_t elem_size,
|
||||
const void *key, size_t *pindex);
|
||||
|
||||
// Using a buffer as a heap
|
||||
void
|
||||
GU_API_DECL void
|
||||
gu_buf_heap_push(GuBuf *buf, GuOrder *order, void *value);
|
||||
|
||||
void
|
||||
GU_API_DECL void
|
||||
gu_buf_heap_pop(GuBuf *buf, GuOrder *order, void* data_out);
|
||||
|
||||
void
|
||||
GU_API_DECL void
|
||||
gu_buf_heap_replace(GuBuf *buf, GuOrder *order, void *value, void *data_out);
|
||||
|
||||
void
|
||||
GU_API_DECL void
|
||||
gu_buf_heapify(GuBuf *buf, GuOrder *order);
|
||||
|
||||
GuSeq*
|
||||
GU_API_DECL GuSeq*
|
||||
gu_buf_freeze(GuBuf* buf, GuPool* pool);
|
||||
#endif // GU_SEQ_H_
|
||||
|
||||
#ifdef GU_STRING_H_
|
||||
void
|
||||
GU_INTERNAL_DECL void
|
||||
gu_buf_require(GuBuf* buf, size_t req_len);
|
||||
#endif // GU_STRING_H_
|
||||
|
||||
@@ -13,7 +13,7 @@ gu_in_utf8(GuIn* in, GuExn* err)
|
||||
gu_in_consume(in, 1);
|
||||
return (GuUCS) i;
|
||||
}
|
||||
extern GuUCS gu_in_utf8_(GuIn* in, GuExn* err);
|
||||
GU_API_DECL GuUCS gu_in_utf8_(GuIn* in, GuExn* err);
|
||||
return gu_in_utf8_(in, err);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ gu_out_utf8(GuUCS ucs, GuOut* out, GuExn* err)
|
||||
if (GU_LIKELY(ucs < 0x80)) {
|
||||
gu_out_u8(out, ucs, err);
|
||||
} else {
|
||||
extern void gu_out_utf8_(GuUCS ucs, GuOut* out, GuExn* err);
|
||||
GU_API_DECL void gu_out_utf8_(GuUCS ucs, GuOut* out, GuExn* err);
|
||||
gu_out_utf8_(ucs, out, err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,10 +35,12 @@
|
||||
typedef uintptr_t GuVariant;
|
||||
|
||||
|
||||
GU_API_DECL
|
||||
void* gu_alloc_variant(uint8_t tag,
|
||||
size_t size, size_t align,
|
||||
GuVariant* variant_out, GuPool* pool);
|
||||
|
||||
GU_API_DECL
|
||||
GuVariant gu_make_variant(uint8_t tag,
|
||||
size_t size, size_t align,
|
||||
const void* init, GuPool* pool);
|
||||
@@ -68,8 +70,10 @@ enum {
|
||||
GU_VARIANT_NULL = -1
|
||||
};
|
||||
|
||||
GU_API_DECL
|
||||
int gu_variant_tag(GuVariant variant);
|
||||
|
||||
GU_API_DECL
|
||||
void* gu_variant_data(GuVariant variant);
|
||||
|
||||
|
||||
@@ -80,8 +84,8 @@ struct GuVariantInfo {
|
||||
void* data;
|
||||
};
|
||||
|
||||
GuVariantInfo gu_variant_open(GuVariant variant);
|
||||
GuVariant gu_variant_close(GuVariantInfo info);
|
||||
GU_API_DECL GuVariantInfo gu_variant_open(GuVariant variant);
|
||||
GU_API_DECL GuVariant gu_variant_close(GuVariantInfo info);
|
||||
|
||||
/** @} */
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#ifndef PGF_GRAPHVIZ_H_
|
||||
#define PGF_GRAPHVIZ_H_
|
||||
|
||||
void
|
||||
PGF_API_DECL void
|
||||
pgf_graphviz_abstract_tree(PgfPGF* pgf, PgfExpr expr, GuOut* out, GuExn* err);
|
||||
|
||||
void
|
||||
PGF_API_DECL void
|
||||
pgf_graphviz_parse_tree(PgfConcr* concr, PgfExpr expr, GuOut* out, GuExn* err);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user