Skip to content

Commit

Permalink
(build) big refactor trying to unclutter shmif headers
Browse files Browse the repository at this point in the history
Cipharius owes me a beer.

FossilOrigin-Name: ff12ca7876ede7e4a52b2a3609312b3e1c6203ae190e61760c19a36c4fbd696b
  • Loading branch information
void committed Feb 3, 2025
1 parent 4d1ba3e commit aa6d2b1
Show file tree
Hide file tree
Showing 71 changed files with 914 additions and 1,931 deletions.
2 changes: 1 addition & 1 deletion external/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Port of LUA5.1 makefiles to CMakeLists for easier build integration
#
PROJECT ( lua51 )
cmake_minimum_required( VERSION 2.8 )
cmake_minimum_required( VERSION 3.5 )

set (MAJOR_VERSION 5 )
set (MINOR_VERSION 1 )
Expand Down
2 changes: 1 addition & 1 deletion external/lua/ldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void DumpVector(const void* b, int n, size_t size, DumpState* D)

static void DumpString(const TString* s, DumpState* D)
{
if (s==NULL || getstr(s)==NULL)
if (s==NULL)
{
size_t size=0;
DumpVar(size,D);
Expand Down
2 changes: 1 addition & 1 deletion external/lua/ltablib.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void addfield (lua_State *L, luaL_Buffer *b, int i) {
if (!lua_isstring(L, -1))
luaL_error(L, "invalid value (%s) at index %d in table for "
LUA_QL("concat"), luaL_typename(L, -1), i);
luaL_addvalue(b);
luaL_addvalue(b);
}


Expand Down
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,13 @@ if (CLIENT_LIBRARY_BUILD OR BUILD_PRESET STREQUAL "client")
endif()
else()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(VPLATFORM_STR "sdl sdl2")
set(VPLATFORM_STR "sdl2")
if (NOT VIDEO_PLATFORM)
set(VIDEO_PLATFORM "sdl2")
endif()
set(CMAKE_INSTALL_LIBDIR /usr/local/share/lib)
else()
set(VPLATFORM_STR "egl-dri, sdl, sdl2, egl-gles")
set(VPLATFORM_STR "egl-dri, sdl2, egl-gles")
if (NOT VIDEO_PLATFORM)
set(VIDEO_PLATFORM "egl-dri")
endif()
Expand Down Expand Up @@ -490,10 +490,10 @@ else()
shmif/arcan_shmif_sub.c
engine/arcan_vr.h
engine/arcan_vr.c
engine/arcan_raster.c
platform/platform.h
platform/video_platform.h
shmif/tui/raster/pixelfont.c
shmif/tui/raster/raster.c
)

# database tool is sqlite3 + libc so less need to work
Expand Down
3 changes: 3 additions & 0 deletions src/a12/a12_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,7 @@ struct appl_meta* a12int_get_directory(struct a12_state*, uint64_t* clk);
* If notify is set changes will be sent dynamically */
void a12int_request_dirlist(struct a12_state*, bool notify);

unsigned long long arcan_timemillis();
void arcan_random(uint8_t* dst, size_t ntc);

#endif
4 changes: 4 additions & 0 deletions src/a12/net/a12_helper_discover.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "anet_helper.h"
#include "hashmap.h"

#ifndef LOG
#define LOG(X, ...) (fprintf(stderr, X, arcan_timemillis(), ## __VA_ARGS__))
#endif

static struct hashmap_s known_beacons;

struct ipcfg {
Expand Down
1 change: 1 addition & 0 deletions src/a12/net/a12_helper_srv.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <stdatomic.h>
#include <pthread.h>

Expand Down
1 change: 1 addition & 0 deletions src/a12/net/dir_cl.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <stdint.h>
#include <signal.h>
#include <stdatomic.h>
#include <pthread.h>

#include "../a12.h"
#include "../a12_int.h"
Expand Down
5 changes: 5 additions & 0 deletions src/a12/net/dir_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include "anet_helper.h"
#include "directory.h"

#ifndef COUNT_OF
#define COUNT_OF(x) \
((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
#endif

#if LUA_VERSION_NUM == 501
#define lua_rawlen(x, y) lua_objlen(x, y)
#endif
Expand Down
1 change: 1 addition & 0 deletions src/a12/net/dir_srv_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <inttypes.h>
#include <stdint.h>
#include <signal.h>
#include <pthread.h>

#include "../a12.h"
#include "../a12_int.h"
Expand Down
1 change: 1 addition & 0 deletions src/a12/net/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <sys/wait.h>
#include <stdarg.h>
#include <ctype.h>
#include <pthread.h>

#include <sys/socket.h>
#include <sys/stat.h>
Expand Down
2 changes: 1 addition & 1 deletion src/engine/arcan_conductor.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ static arcan_tick_cb outcb;
static void conductor_cycle(int);
int arcan_conductor_run(arcan_tick_cb tick)
{
arcan_evctx* evctx = arcan_event_defaultctx();
struct arcan_evctx* evctx = arcan_event_defaultctx();
outcb = tick;
int exit_code = EXIT_FAILURE;
alloc_frameserver_struct();
Expand Down
36 changes: 19 additions & 17 deletions src/engine/arcan_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

typedef struct queue_cell queue_cell;

static arcan_event eventbuf[ARCAN_EVENT_QUEUE_LIM];
static struct arcan_event eventbuf[ARCAN_EVENT_QUEUE_LIM];

static uint8_t eventfront = 0, eventback = 0;
static int64_t epoch;
Expand Down Expand Up @@ -83,15 +83,16 @@ static struct pollfd evsrc_pollset[64];
static struct evsrc_meta evsrc_meta[64];
static uint64_t evsrc_bitmap;

arcan_evctx* arcan_event_defaultctx(){
struct arcan_evctx* arcan_event_defaultctx()
{
return &default_evctx;
}

/*
* If the shmpage integrity is somehow compromised,
* if semaphore use is out of order etc.
*/
static void pull_killswitch(arcan_evctx* ctx)
static void pull_killswitch(struct arcan_evctx* ctx)
{
arcan_frameserver* ks = (arcan_frameserver*) ctx->synch.killswitch;
arcan_sem_post(ctx->synch.handle);
Expand All @@ -101,17 +102,17 @@ static void pull_killswitch(arcan_evctx* ctx)
ctx->synch.killswitch = NULL;
}

static bool queue_full(arcan_evctx* ctx)
static bool queue_full(struct arcan_evctx* ctx)
{
return (((*ctx->back + 1) % ctx->eventbuf_sz) == *ctx->front);
}

static bool queue_empty(arcan_evctx* ctx)
static bool queue_empty(struct arcan_evctx* ctx)
{
return (*ctx->front == *ctx->back);
}

int arcan_event_poll(arcan_evctx* ctx, struct arcan_event* dst)
int arcan_event_poll(struct arcan_evctx* ctx, struct arcan_event* dst)
{
assert(dst);
if (queue_empty(ctx))
Expand Down Expand Up @@ -158,22 +159,22 @@ void arcan_event_repl(struct arcan_evctx* ctx, enum ARCAN_EVENT_CATEGORY cat,

}

void arcan_event_maskall(arcan_evctx* ctx)
void arcan_event_maskall(struct arcan_evctx* ctx)
{
ctx->mask_cat_inp = 0xffffffff;
}

void arcan_event_clearmask(arcan_evctx* ctx)
void arcan_event_clearmask(struct arcan_evctx* ctx)
{
ctx->mask_cat_inp = 0;
}

void arcan_event_setmask(arcan_evctx* ctx, uint32_t mask)
void arcan_event_setmask(struct arcan_evctx* ctx, uint32_t mask)
{
ctx->mask_cat_inp = mask;
}

int arcan_event_denqueue(arcan_evctx* ctx, const struct arcan_event* const src)
int arcan_event_denqueue(struct arcan_evctx* ctx, const struct arcan_event* const src)
{
if (ctx->drain){
arcan_event ev = *src;
Expand All @@ -191,7 +192,7 @@ int arcan_event_denqueue(arcan_evctx* ctx, const struct arcan_event* const src)
* implementation to support waking up the child, and that blocking behaviors
* in the main thread is always forbidden.
*/
int arcan_event_enqueue(arcan_evctx* ctx, const struct arcan_event* const src)
int arcan_event_enqueue(struct arcan_evctx* ctx, const struct arcan_event* const src)
{
/* early-out mask-filter, these are only ever used to silently
* discard input / output (only operate on head and tail of ringbuffer) */
Expand Down Expand Up @@ -258,7 +259,7 @@ int arcan_event_enqueue(arcan_evctx* ctx, const struct arcan_event* const src)
return ARCAN_OK;
}

static inline int queue_used(arcan_evctx* dq)
static inline int queue_used(struct arcan_evctx* dq)
{
int rv = *(dq->front) > *(dq->back) ? dq->eventbuf_sz -
*(dq->front) + *(dq->back) : *(dq->back) - *(dq->front);
Expand Down Expand Up @@ -327,7 +328,8 @@ static bool append_bufferstream(struct arcan_frameserver* tgt, arcan_extevent* e
}


int arcan_event_queuetransfer(arcan_evctx* dstqueue, arcan_evctx* srcqueue,
int arcan_event_queuetransfer(
struct arcan_evctx* dstqueue, struct arcan_evctx* srcqueue,
enum ARCAN_EVENT_CATEGORY allowed, float sat, struct arcan_frameserver* tgt)
{
if (!srcqueue || !dstqueue || (srcqueue && !srcqueue->front)
Expand Down Expand Up @@ -558,7 +560,7 @@ int64_t arcan_frametime()
return now - epoch;
}

float arcan_event_process(arcan_evctx* ctx, arcan_tick_cb cb)
float arcan_event_process(struct arcan_evctx* ctx, arcan_tick_cb cb)
{
int64_t base = ctx->c_ticks * ARCAN_TIMER_TICK;
int64_t delta = arcan_frametime() - base;
Expand Down Expand Up @@ -649,7 +651,7 @@ void arcan_bench_register_frame()
lastframe = ftime;
}

void arcan_event_deinit(arcan_evctx* ctx, bool flush)
void arcan_event_deinit(struct arcan_evctx* ctx, bool flush)
{
platform_event_deinit(ctx);

Expand Down Expand Up @@ -826,14 +828,14 @@ bool arcan_event_del_source(
return false;
}

void arcan_event_setdrain(arcan_evctx* ctx, arcan_event_handler drain)
void arcan_event_setdrain(struct arcan_evctx* ctx, arcan_event_handler drain)
{
if (!ctx->local)
return;
ctx->drain = drain;
}

void arcan_event_init(arcan_evctx* ctx)
void arcan_event_init(struct arcan_evctx* ctx)
{
/*
* non-local (i.e. shmpage resident) event queues has a different
Expand Down
4 changes: 2 additions & 2 deletions src/engine/arcan_frameserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ struct arcan_frameserver {

/* signaling primitives */
sem_handle vsync, async, esync;
file_handle dpipe;
int dpipe;

/* if we spawn child, track if it is alive */
process_handle child;
Expand Down Expand Up @@ -378,7 +378,7 @@ bool arcan_frameserver_tick_control(arcan_frameserver* src, bool tick, int ff);
* filter events that are outside the accepted category / kind maintained
* in the frameserver struct
*/
void arcan_frameserver_pollevent(arcan_frameserver*, arcan_evctx*);
void arcan_frameserver_pollevent(arcan_frameserver*, struct arcan_evctx*);

/*
* Attempt to retrieve a copy of the current LUT-ramps for a specific
Expand Down
2 changes: 1 addition & 1 deletion src/engine/arcan_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ int MAIN_REDIR(int argc, char* argv[])
fullscreen = false;

/* grab video, (necessary) */
arcan_evctx* evctx = arcan_event_defaultctx();
struct arcan_evctx* evctx = arcan_event_defaultctx();
arcan_event_init(evctx);

if (arcan_video_init(width, height, 32, fullscreen, windowed,
Expand Down
Loading

0 comments on commit aa6d2b1

Please sign in to comment.