Skip to content

Commit f965b0c

Browse files
committed
Merge branch 'zephyr' of https://git.moddable.tech:3000/git/moddable into zephyr
2 parents ff34cba + a9aa874 commit f965b0c

File tree

7 files changed

+56
-21
lines changed

7 files changed

+56
-21
lines changed

modules/piu/MC/piuView.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ void PiuViewUpdateStep(PiuView* self, PocoCoordinate x, PocoCoordinate y, PocoDi
11641164
result = PocoDrawingEnd(poco, poco->pixels, poco->pixelsLength, PiuViewDisplayReceiver, self);
11651165
#else
11661166
xsCallFunction4((*self)->_begin, xsReference((*self)->screen), xsInteger(poco->x), xsInteger(poco->y), xsInteger(poco->w), xsInteger(poco->h));
1167-
result = PocoDrawingEnd(poco, poco->pixels, poco->pixelsLength, PiuViewDisplayReceiver, self);
1167+
result = PocoDrawingEnd(poco, poco->pixels, poco->pixelsLength, PiuViewReceiver, self);
11681168
#endif
11691169
}
11701170
if (result) goto fail;

tools/test262/_262.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@
9191
#define fxUnlockMutex(MUTEX) LeaveCriticalSection(MUTEX)
9292
#define fxSleepCondition(CONDITION,MUTEX) SleepConditionVariableCS(CONDITION,MUTEX,INFINITE)
9393
#define fxWakeCondition(CONDITION) WakeConditionVariable(CONDITION)
94+
#elif _ZEPHYR
95+
96+
typedef uint32_t txCondition;
97+
typedef void *txMutex;
98+
typedef void *txThread;
99+
#define fxCreateCondition(CONDITION)
100+
#define fxSleepCondition(CONDITION,MUTEX)
101+
#define fxWakeCondition(CONDITION)
102+
103+
#define fxCreateMutex(MUTEX)
104+
#define fxDeleteMutex(MUTEX)
105+
#define fxLockMutex(MUTEX)
106+
#define fxUnlockMutex(MUTEX)
94107
#else
95108
#include <dirent.h>
96109
#include <pthread.h>
@@ -381,7 +394,7 @@ void _262_agent_broadcast(txMachine* the)
381394
gxAgentCluster.dataValue = xsToInteger(xsArg(1));
382395
#if mxWindows
383396
WakeAllConditionVariable(&(gxAgentCluster.dataCondition));
384-
#elif PICO_BUILD
397+
#elif PICO_BUILD || _ZEPHYR
385398
#else
386399
pthread_cond_broadcast(&(gxAgentCluster.dataCondition));
387400
#endif
@@ -468,7 +481,7 @@ void _262_agent_sleep(txMachine* the)
468481
xsIntegerValue delay = xsToInteger(xsArg(0));
469482
#ifdef mxUseFreeRTOSTasks
470483
vTaskDelay(pdMS_TO_TICKS(delay));
471-
#elif PICO_BUILD
484+
#elif PICO_BUILD || _ZEPHYR
472485
modDelayMilliseconds(delay);
473486
#elif mxWindows
474487
Sleep(delay);
@@ -501,7 +514,7 @@ void _262_agent_start(txMachine* the)
501514
xTaskCreate(_262_agent_start_aux, "agent", kStack, agent, 8, &(agent->thread));
502515
#elif mxWindows
503516
agent->thread = (HANDLE)_beginthreadex(NULL, 0, _262_agent_start_aux, agent, 0, NULL);
504-
#elif PICO_BUILD
517+
#elif PICO_BUILD || _ZEPHYR
505518
_262_agent_start_aux(agent);
506519
#else
507520
pthread_create(&(agent->thread), NULL, &_262_agent_start_aux, agent);
@@ -588,7 +601,7 @@ void _262_agent_stop(txMachine* the)
588601
#if mxWindows
589602
WaitForSingleObject(agent->thread, INFINITE);
590603
CloseHandle(agent->thread);
591-
#elif PICO_BUILD
604+
#elif PICO_BUILD || _ZEPHYR
592605
#else
593606
pthread_join(agent->thread, NULL);
594607
#endif

tools/test262/manifest.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"esp32/moddable_six_cdc": {
7676
"build": {
7777
"ESP32_SUBCLASS": "esp32s3",
78+
"EXPECTED_ESP_IDF": "v5.5.1",
7879
"USE_USB": "2",
7980
"SDKCONFIGPATH": "$(MODDABLE)/build/devices/esp32/targets/moddable_six_cdc/sdkconfig"
8081
},
@@ -153,6 +154,22 @@
153154
"$(MODULES)/base/timer/win/*"
154155
]
155156
}
157+
},
158+
"zephyr": {
159+
"build": {
160+
"MAKE_FRAGMENT": "$(MODDABLE)/build/devices/zephyr/config/CMakeLists.txt",
161+
"ZEPHYR_BOARD": "$(SUBPLATFORM)"
162+
},
163+
"defines": {
164+
"XS_TEST": 1
165+
},
166+
"modules": {
167+
"*": [
168+
"$(MODULES)/base/timer/*",
169+
"$(MODULES)/base/timer/mc/*",
170+
"$(MODULES)/files/resource/Resource"
171+
]
172+
}
156173
}
157174
}
158175
}

xs/platforms/zephyr/xsHost.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -762,21 +762,17 @@ uint32_t espRead32be(const void *addr)
762762
return (result << 24) | ((result & 0xff00) << 8) | ((result >> 8) & 0xff00) | (result >> 24);
763763
}
764764

765-
void undefinedFail(const char *what) {
765+
static void undefinedFail(const char *what) {
766766
char msg[64];
767767
c_strcpy(msg, "unimplemented: ");
768768
c_strcat(msg, what);
769-
modLog_transmit(msg);
769+
modLog_transmit(msg);
770770
}
771771

772772
void vSemaphoreDelete() {undefinedFail("vSemaphoreDelete"); }
773773
void xSemaphoreGive() {undefinedFail("xSemaphoreGive"); }
774774
void xSemaphoreTake() {undefinedFail("xSemaphoreTake"); }
775775

776-
void qsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *)) { undefinedFail("qsort"); }
777-
void * bsearch(const void *key, const void *base, size_t nel, size_t width, int (*compar) (const void *, const void *)) { undefinedFail("bsearch"); return NULL; }
778-
779-
780776
static int32_t gTimeZoneOffset = -8 * 60 * 60; // Menlo Park
781777
static int16_t gDaylightSavings = 60 * 60; // summer time
782778

xs/platforms/zephyr/xsHost.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ typedef void (*modMessageDeliver)(void *the, void *refcon, uint8_t *message, uin
220220
#define MOD_TASKS (true)
221221
#define modTaskGetCurrent() ((uintptr_t)k_current_get());
222222

223+
#if MODDEF_XS_TEST
224+
extern uint8_t gSoftReset;
225+
#define modSoftReset() gSoftReset = 1
226+
#endif
227+
223228
/*
224229
c libraries
225230
*/
@@ -232,11 +237,6 @@ typedef void (*modMessageDeliver)(void *the, void *refcon, uint8_t *message, uin
232237
#include <stdio.h>
233238
#include <stdlib.h>
234239

235-
#ifndef PATH_MAX
236-
#define PATH_MAX 128
237-
#endif
238-
239-
240240
#define c_tolower tolower
241241
#define c_toupper toupper
242242

@@ -296,9 +296,13 @@ extern int gettimeofday(void *tv, void *unusedTZ);
296296
#define C_EINVAL EINVAL
297297

298298
#ifndef PATH_MAX
299-
#define PATH_MAX 128
299+
#if MODDEF_XS_TEST
300+
#define PATH_MAX (128)
301+
#else
302+
#define PATH_MAX (256)
303+
#endif
300304
#endif
301-
#define C_PATH_MAX 128 // PATH_MAX
305+
#define C_PATH_MAX (PATH_MAX)
302306

303307
/* MATH */
304308
#if 0 // fdlibm
@@ -420,9 +424,6 @@ extern int gettimeofday(void *tv, void *unusedTZ);
420424
#define c_tanh tanh
421425
#define c_trunc trunc
422426

423-
void qsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *));
424-
void *bsearch(const void *key, const void *base, size_t nel, size_t width, int (*compar)(const void *, const void*));
425-
426427
#define _M_LN2 0.693147180559945309417
427428
#define M_E 2.7182818284590452354
428429
#define M_LOG2E 1.4426950408889634074

xs/platforms/zephyr/xsPlatform.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ void fx_putpi(txMachine *the, char separator, txBoolean trailingcrlf)
211211

212212
void fxAbort(txMachine* the, int status)
213213
{
214+
#if MODDEF_XS_TEST
215+
if (XS_DEBUGGER_EXIT == status) {
216+
modSoftReset();
217+
return;
218+
}
219+
#endif
220+
214221
char *msg = (char*)fxAbortString(status);
215222
char *reason = "";
216223
if (XS_UNHANDLED_EXCEPTION_EXIT == status) {

xs/platforms/zephyr/xsPlatform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#endif
5252
// #define mxUseFreeRTOSTasks 1
5353
// #define mxUseGCCAtomics 1 // undefine
54+
#define mxMisalignedSettersCrash 1
5455

5556
#ifndef __XS6PLATFORMMINIMAL__
5657

0 commit comments

Comments
 (0)