Skip to content

Commit

Permalink
Enforce C linkage everywhere
Browse files Browse the repository at this point in the history
in order to compile Julia with a C++ compiler (specifically MSVC)
  • Loading branch information
tkelman committed Mar 31, 2014
1 parent d56088a commit e7955dd
Show file tree
Hide file tree
Showing 49 changed files with 387 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "julia.h"
#include "julia_internal.h"

#ifdef __cplusplus
extern "C" {
#endif

jl_value_t *jl_true;
jl_value_t *jl_false;

Expand Down Expand Up @@ -931,3 +935,7 @@ JL_CALLABLE(jl_f_default_ctor_2)
jl_type_error(((jl_datatype_t*)F)->name->name->name, ft, args[1]);
return jl_new_struct((jl_datatype_t*)F, args[0], args[1]);
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#include "julia.h"
#include "julia_internal.h"

#ifdef __cplusplus
extern "C" {
#endif

// array constructors ---------------------------------------------------------

static inline int store_unboxed(jl_value_t *el_type)
Expand Down Expand Up @@ -711,3 +715,7 @@ DLLEXPORT void jl_cell_1d_push2(jl_array_t *a, jl_value_t *b, jl_value_t *c)
jl_cellset(a, jl_array_dim(a,0)-2, b);
jl_cellset(a, jl_array_dim(a,0)-1, c);
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#include "julia_internal.h"
#include "flisp.h"

#ifdef __cplusplus
extern "C" {
#endif

// MSVC complains about "julia_flisp.boot.inc : error C4335: Mac file format
// detected: please convert the source file to either DOS or UNIX format"
#ifdef _MSC_VER
Expand Down Expand Up @@ -860,3 +864,7 @@ jl_value_t *jl_prepare_ast(jl_lambda_info_t *li, jl_tuple_t *sparams)
JL_GC_POP();
return ast;
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/builtin_proto.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef BUILTIN_PROTO_H
#define BUILTIN_PROTO_H

#ifdef __cplusplus
extern "C" {
#endif

// declarations for julia-callable builtin functions

JL_CALLABLE(jl_f_new_expr);
Expand Down Expand Up @@ -38,4 +42,8 @@ JL_CALLABLE(jl_f_invoke);
JL_CALLABLE(jl_f_task);
JL_CALLABLE(jl_f_yieldto);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "julia_internal.h"
#include "builtin_proto.h"

#ifdef __cplusplus
extern "C" {
#endif

// exceptions -----------------------------------------------------------------

DLLEXPORT void jl_error(const char *str)
Expand Down Expand Up @@ -1354,3 +1358,7 @@ DLLEXPORT void jl_breakpoint(jl_value_t* v)
{
// put a breakpoint in you debugger here
}

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ static Type *NoopType;

// --- utilities ---

extern "C" {
#if defined(JULIA_TARGET_CORE2)
const char *jl_cpu_string = "core2";
#elif defined(JULIA_TARGET_NATIVE)
Expand All @@ -453,7 +454,6 @@ const char *jl_cpu_string = "native";
#error "Must select julia cpu target"
#endif

extern "C" {
int globalUnique = 0;
}

Expand Down
8 changes: 8 additions & 0 deletions src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <dlfcn.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

#if defined(__APPLE__)
static char *extensions[] = { "", ".dylib" };
#define N_EXTENSIONS 2
Expand Down Expand Up @@ -207,3 +211,7 @@ char *jl_dlfind_win32(char *f_name)
// appropriate error.
}
#endif

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "julia_internal.h"
#include "builtin_proto.h"

#ifdef __cplusplus
extern "C" {
#endif

static htable_t ser_tag;
static htable_t deser_tag;
static htable_t backref_table;
Expand Down Expand Up @@ -1341,3 +1345,7 @@ void jl_init_serializer(void)
i += 1;
}
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/flisp/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include <sys/time.h>
#endif /* !_OS_WINDOWS_ */

#ifdef __cplusplus
extern "C" {
#endif

size_t llength(value_t v)
{
size_t n = 0;
Expand Down Expand Up @@ -419,3 +423,7 @@ void builtins_init(void)
table_init();
iostream_init();
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/flisp/equalhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,12 @@

#define _equal_lispvalue_(x,y) equal_lispvalue((value_t)(x),(value_t)(y))

#ifdef __cplusplus
extern "C" {
#endif

HTIMPL(equalhash, hash_lispvalue, _equal_lispvalue_)

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/flisp/equalhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

#include "htable.h"

#ifdef __cplusplus
extern "C" {
#endif

HTPROT(equalhash)

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions src/flisp/flisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ char * dirname(char *);
#include "flisp.h"
#include "opcodes.h"

#ifdef __cplusplus
extern "C" {
#endif

static char *builtin_names[] =
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
Expand Down Expand Up @@ -2531,3 +2535,7 @@ int fl_load_system_image(value_t sys_image_iostream)
POPN(1);
return 0;
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/flisp/flisp.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ typedef int_t fixnum_t;
#define T_FIXNUM T_INT32
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
value_t car;
value_t cdr;
Expand Down Expand Up @@ -383,4 +387,8 @@ value_t cvalue_wchar(value_t *args, uint32_t nargs);
void fl_init(size_t initial_heapsize);
int fl_load_system_image(value_t ios);

#ifdef __cplusplus
}
#endif

#endif
8 changes: 8 additions & 0 deletions src/flisp/flmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include "flisp.h"
#include "opcodes.h"

#ifdef __cplusplus
extern "C" {
#endif

static value_t argv_list(int argc, char *argv[])
{
int i;
Expand Down Expand Up @@ -58,3 +62,7 @@ int main(int argc, char *argv[])
}
return 0;
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/flisp/iostream.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <setjmp.h>
#include "flisp.h"

#ifdef __cplusplus
extern "C" {
#endif

static value_t iostreamsym, rdsym, wrsym, apsym, crsym, truncsym;
static value_t instrsym, outstrsym;
fltype_t *iostreamtype;
Expand Down Expand Up @@ -450,3 +454,7 @@ void iostream_init(void)
setc(symbol("*stdin*" ), cvalue_from_ref(iostreamtype, ios_stdin,
sizeof(ios_t), FL_NIL));
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/flisp/julia_extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "flisp.h"
#include "utf8proc.h"

#ifdef __cplusplus
extern "C" {
#endif

static int is_uws(uint32_t wc)
{
return (wc==9 || wc==10 || wc==11 || wc==12 || wc==13 || wc==32 ||
Expand Down Expand Up @@ -108,3 +112,7 @@ void fl_init_julia_extensions(void)
{
assign_global_builtins(julia_flisp_func_info);
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/flisp/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include <sys/time.h>
#endif /* !_OS_WINDOWS_ */

#ifdef __cplusplus
extern "C" {
#endif

value_t fl_stringp(value_t *args, u_int32_t nargs)
{
argcount("string?", nargs, 1);
Expand Down Expand Up @@ -432,3 +436,7 @@ void stringfuncs_init(void)
{
assign_global_builtins(stringfunc_info);
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/flisp/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "flisp.h"
#include "equalhash.h"

#ifdef __cplusplus
extern "C" {
#endif

static value_t tablesym;
static fltype_t *tabletype;

Expand Down Expand Up @@ -208,3 +212,7 @@ void table_init(void)
&table_vtable, NULL);
assign_global_builtins(tablefunc_info);
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#define GC_PAGE_SZ (2048*sizeof(void*))//bytes
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _gcpage_t {
char data[GC_PAGE_SZ];
union {
Expand Down Expand Up @@ -1151,3 +1155,7 @@ static void big_obj_stats(void)
JL_PRINTF(JL_STDOUT, "%d bytes in %d large objects\n", nbytes, nused);
}
#endif //MEMPROFILE

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "julia.h"
#include "julia_internal.h"

#ifdef __cplusplus
extern "C" {
#endif

static jl_methtable_t *new_method_table(jl_sym_t *name)
{
jl_methtable_t *mt = (jl_methtable_t*)allocobj(sizeof(jl_methtable_t));
Expand Down Expand Up @@ -1633,3 +1637,7 @@ jl_value_t *jl_matching_methods(jl_function_t *gf, jl_value_t *type, int lim)
jl_methtable_t *mt = jl_gf_mtable(gf);
return ml_matches(mt->defs, type, jl_gf_name(gf), lim);
}

#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include "julia_internal.h"
#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

#ifdef _OS_WINDOWS_
#define WIN32_LEAN_AND_MEAN
// Copied from MINGW_FLOAT_H which may not be found due to a colision with the builtin gcc float.h
Expand Down Expand Up @@ -974,3 +978,7 @@ DLLEXPORT void jl_get_system_hooks(void)
jl_loaderror_type = (jl_datatype_t*)basemod("LoadError");
jl_weakref_type = (jl_datatype_t*)basemod("WeakRef");
}

#ifdef __cplusplus
}
#endif
Loading

0 comments on commit e7955dd

Please sign in to comment.