Skip to content

Reorganization of files to allow distribution of Julia for embedding without uv.h #8880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#include "julia.h"
#include "julia_internal.h"

#ifdef __cplusplus
Expand Down
1 change: 0 additions & 1 deletion src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#ifdef _OS_WINDOWS_
#include <malloc.h>
#endif
#include "julia.h"
#include "julia_internal.h"

#ifdef __cplusplus
Expand Down
1 change: 0 additions & 1 deletion src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifdef _OS_WINDOWS_
#include <malloc.h>
#endif
#include "julia.h"
#include "julia_internal.h"
#include "flisp.h"

Expand Down
2 changes: 1 addition & 1 deletion src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include <math.h>
#endif
#include <ctype.h>
#include "julia.h"
#include "julia_internal.h"
#include "ios_internal.h"
#include "builtin_proto.h"

#ifdef __cplusplus
Expand Down
1 change: 0 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@
#define NOMINMAX
#endif

#include "julia.h"
#include "julia_internal.h"

#include <setjmp.h>
Expand Down
1 change: 0 additions & 1 deletion src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <sys/stat.h>

#include "platform.h"
#include "julia.h"
#include "julia_internal.h"
#ifdef _OS_WINDOWS_
#include <windows.h>
Expand Down
2 changes: 1 addition & 1 deletion src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#ifdef _OS_WINDOWS_
#include <malloc.h>
#endif
#include "julia.h"
#include "julia_internal.h"
#include "ios_internal.h"
#include "builtin_proto.h"

#ifdef __cplusplus
Expand Down
1 change: 1 addition & 0 deletions src/flisp/flisp.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

#include "platform.h"
#include "libsupport.h"
#include "ios_internal.h"
#include "flisp.h"
#include "opcodes.h"

Expand Down
1 change: 1 addition & 0 deletions src/flisp/iostream.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <sys/types.h>
#include <setjmp.h>
#include "flisp.h"
#include "ios_internal.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions src/flisp/julia_extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <assert.h>
#include "flisp.h"
#include "mojibake.h"
#include "ios_internal.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 0 additions & 1 deletion src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# include <sys/mman.h>
# include <malloc.h>
#endif
#include "julia.h"
#include "julia_internal.h"

#ifdef _P64
Expand Down
1 change: 0 additions & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#ifdef _OS_WINDOWS_
#include <malloc.h>
#endif
#include "julia.h"
#include "julia_internal.h"

#ifdef __cplusplus
Expand Down
1 change: 0 additions & 1 deletion src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <getopt.h>
#endif

#include "julia.h"
#include "julia_internal.h"
#include <stdio.h>

Expand Down
1 change: 0 additions & 1 deletion src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#ifdef _OS_WINDOWS_
#include <malloc.h>
#endif
#include "julia.h"
#include "julia_internal.h"
#include "builtin_proto.h"

Expand Down
2 changes: 1 addition & 1 deletion src/jl_uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include <sys/socket.h>
#endif

#include "julia.h"
#include "julia_internal.h"
#include "support/ios.h"
#include "support/ios_internal.h"
#include "uv.h"

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/jlapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "julia.h"
#include "julia_internal.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 0 additions & 1 deletion src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#ifdef _OS_WINDOWS_
#include <malloc.h>
#endif
#include "julia.h"
#include "julia_internal.h"
#include "builtin_proto.h"

Expand Down
25 changes: 12 additions & 13 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
extern "C" {
#endif

#ifndef UV_H
typedef struct uv_stream_s uv_stream_t;
typedef struct uv_async_s uv_async_t;
typedef struct uv_loop_s uv_loop_t;
typedef struct uv_process_s uv_process_t;
typedef struct uv_pipe_s uv_pipe_t;
typedef struct uv_handle_s uv_handle_t;
typedef struct uv_idle_s uv_idle_t;
typedef struct uv_timer_s uv_timer_t;
typedef struct uv_tcp_s uv_tcp_t;
#endif

#include "options.h"

#include "libsupport.h"
Expand Down Expand Up @@ -1244,12 +1256,6 @@ void jl_longjmp(jmp_buf _Buf,int _Value);
#define JL_PUTS jl_puts
#define JL_WRITE jl_write

DLLEXPORT int jl_spawn(char *name, char **argv, uv_loop_t *loop,
uv_process_t *proc, jl_value_t *julia_struct,
uv_handle_type stdin_type,uv_pipe_t *stdin_pipe,
uv_handle_type stdout_type,uv_pipe_t *stdout_pipe,
uv_handle_type stderr_type,uv_pipe_t *stderr_pipe,
int detach, char **env, char *cwd);
DLLEXPORT void jl_run_event_loop(uv_loop_t *loop);
DLLEXPORT int jl_run_once(uv_loop_t *loop);
DLLEXPORT int jl_process_events(uv_loop_t *loop);
Expand Down Expand Up @@ -1291,13 +1297,6 @@ DLLEXPORT void *jl_takebuf_raw(ios_t *s);
DLLEXPORT jl_value_t *jl_readuntil(ios_t *s, uint8_t delim);
DLLEXPORT void jl_free2(void *p, void *hint);

typedef struct {
void *data;
uv_loop_t *loop;
uv_handle_type type;
uv_file file;
} jl_uv_file_t;

DLLEXPORT size_t jl_write(uv_stream_t *stream, const char *str, size_t n);
DLLEXPORT int jl_printf(uv_stream_t *s, const char *format, ...);
DLLEXPORT int jl_vprintf(uv_stream_t *s, const char *format, va_list args);
Expand Down
16 changes: 16 additions & 0 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@

#include "options.h"
#include "uv.h"
#include "julia.h"
#include "ios_internal.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
void *data;
uv_loop_t *loop;
uv_handle_type type;
uv_file file;
} jl_uv_file_t;

STATIC_INLINE jl_value_t *newobj(jl_value_t *type, size_t nfields)
{
jl_value_t *jv = (jl_value_t*)allocobj((1+nfields) * sizeof(void*));
Expand Down Expand Up @@ -139,8 +148,15 @@ extern uv_lib_t *jl_crtdll_handle;
extern uv_lib_t *jl_winsock_handle;
#endif

DLLEXPORT int jl_spawn(char *name, char **argv, uv_loop_t *loop,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably not be inside an #ifdef __cplusplus

uv_process_t *proc, jl_value_t *julia_struct,
uv_handle_type stdin_type,uv_pipe_t *stdin_pipe,
uv_handle_type stdout_type,uv_pipe_t *stdout_pipe,
uv_handle_type stderr_type,uv_pipe_t *stderr_pipe,
int detach, char **env, char *cwd);
#ifdef __cplusplus
}

#endif

#endif
1 change: 0 additions & 1 deletion src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
modules and top-level bindings
*/
#include <assert.h>
#include "julia.h"
#include "julia_internal.h"

#ifdef __cplusplus
Expand Down
1 change: 0 additions & 1 deletion src/profile.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include "julia.h"
#include "julia_internal.h"

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion src/support/ios.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "utils.h"
#include "utf8.h"
#include "ios.h"
#include "ios_internal.h"
#include "timefuncs.h"

#define MOST_OF(x) ((x) - ((x)>>4))
Expand Down
55 changes: 3 additions & 52 deletions src/support/ios.h
Original file line number Diff line number Diff line change
@@ -1,73 +1,25 @@
#ifndef IOS_H
#define IOS_H

#include <sys/types.h>
#include <stdarg.h>
#include "uv.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct ios_t ios_t;

// this flag controls when data actually moves out to the underlying I/O
// channel. memory streams are a special case of this where the data
// never moves out.

//make it compatible with UV Handles
typedef enum { bm_none=UV_HANDLE_TYPE_MAX+1, bm_line, bm_block, bm_mem } bufmode_t;
typedef enum { bst_none, bst_rd, bst_wr } bufstate_t;

#define IOS_INLSIZE 54
#define IOS_BUFSIZE 131072

typedef struct {
// the state only indicates where the underlying file position is relative
// to the buffer. reading: at the end. writing: at the beginning.
// in general, you can do any operation in any state.
char *buf; // start of buffer

int errcode;

#ifdef _P64
int _pad_bm; // put bm at same offset as type field of uv_stream_s
#endif
bufmode_t bm; //
bufstate_t state;

off_t maxsize; // space allocated to buffer
off_t size; // length of valid data in buf, >=ndirty
off_t bpos; // current position in buffer
off_t ndirty; // # bytes at &buf[0] that need to be written

off_t fpos; // cached file pos
size_t lineno; // current line number

// pointer-size integer to support platforms where it might have
// to be a pointer
long fd;

unsigned char readable:1;
unsigned char writable:1;
unsigned char ownbuf:1;
unsigned char ownfd:1;
unsigned char _eof:1;

// this means you can read, seek back, then read the same data
// again any number of times. usually only true for files and strings.
unsigned char rereadable:1;

// this enables "stenciled writes". you can alternately write and
// seek without flushing in between. this performs read-before-write
// to populate the buffer, so "rereadable" capability is required.
// this is off by default.
//unsigned char stenciled:1;

// request durable writes (fsync)
// unsigned char durable:1;

int64_t userdata;
char local[IOS_INLSIZE];
} ios_t;

/* low-level interface functions */
DLLEXPORT size_t ios_read(ios_t *s, char *dest, size_t n);
DLLEXPORT size_t ios_readall(ios_t *s, char *dest, size_t n);
Expand All @@ -85,7 +37,6 @@ DLLEXPORT int ios_isopen(ios_t *s);
DLLEXPORT char *ios_takebuf(ios_t *s, size_t *psize); // release buffer to caller
// set buffer space to use
DLLEXPORT int ios_setbuf(ios_t *s, char *buf, size_t size, int own);
DLLEXPORT int ios_bufmode(ios_t *s, bufmode_t mode);
DLLEXPORT int ios_get_readable(ios_t *s);
DLLEXPORT int ios_get_writable(ios_t *s);
DLLEXPORT void ios_set_readonly(ios_t *s);
Expand Down
Loading