Skip to content

Commit 0f494e6

Browse files
authored
Fix a few signature that were using long types. NFC (#18998)
The emscripten_request_animation_frame sig was just wrong since that Web API returns WebIDL `long` defined as i32. For emscripten_webgl_get_parameter_i64v use GLint64 rather than `long long` to me more explicit. For `emscripten_websocket_get_buffered_amount` using `size_t` since we already include `stdint.h` in this header anyway. I found all of these while working on #18985 which detectes the use of `long`, `size_t` or pointers and marks tham a `p` in their `__sig` attribute.
1 parent 04eb42d commit 0f494e6

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/library_websocket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var LibraryWebSocket = {
3838
return {{{ cDefine('EMSCRIPTEN_RESULT_INVALID_TARGET') }}};
3939
}
4040

41-
{{{ makeSetValue('bufferedAmount', '0', 'socket.bufferedAmount', 'i64') }}};
41+
{{{ makeSetValue('bufferedAmount', '0', 'socket.bufferedAmount', '*') }}};
4242
return {{{ cDefine('EMSCRIPTEN_RESULT_SUCCESS') }}};
4343
},
4444

system/include/emscripten/html5.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ void emscripten_html5_remove_all_event_listeners(void);
476476
#define emscripten_set_batterylevelchange_callback(userData, callback) emscripten_set_batterylevelchange_callback_on_thread( (userData), (callback), EM_CALLBACK_THREAD_CONTEXT_CALLING_THREAD)
477477
#define emscripten_set_beforeunload_callback(userData, callback) emscripten_set_beforeunload_callback_on_thread( (userData), (callback), EM_CALLBACK_THREAD_CONTEXT_MAIN_RUNTIME_THREAD)
478478

479-
long emscripten_request_animation_frame(EM_BOOL (*cb)(double time, void *userData), void *userData);
480-
void emscripten_cancel_animation_frame(long requestAnimationFrameId);
479+
int emscripten_request_animation_frame(EM_BOOL (*cb)(double time, void *userData), void *userData);
480+
void emscripten_cancel_animation_frame(int requestAnimationFrameId);
481481
void emscripten_request_animation_frame_loop(EM_BOOL (*cb)(double time, void *userData), void *userData);
482482

483483
double emscripten_date_now(void);

system/include/emscripten/html5_webgl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ void *emscripten_webgl_get_proc_address(const char *name __attribute__((nonnull)
100100

101101
#define GLint int
102102
#define GLenum int
103+
#define GLint64 long long int
103104

104105
#define EMSCRIPTEN_WEBGL_PARAM_TYPE int
105106
#define EMSCRIPTEN_WEBGL_PARAM_TYPE_INT 0
@@ -188,12 +189,13 @@ GLint emscripten_webgl_get_parameter_o(GLenum param);
188189
char *emscripten_webgl_get_parameter_utf8(GLenum param);
189190

190191
// Calls GLctx.getParameter():
191-
// Returns the given WebGL context state as long long, written to the given heap location.
192+
// Returns the given WebGL context state as GLint64, written to the given heap location.
192193
// Call this function only for values of 'param' that return a WebGL Number type.
193-
void emscripten_webgl_get_parameter_i64v(GLenum param, long long *dst __attribute__((nonnull)));
194+
void emscripten_webgl_get_parameter_i64v(GLenum param, GLint64 *dst __attribute__((nonnull)));
194195

195196
#undef GLint
196197
#undef GLenum
198+
#undef GLint64
197199

198200
#ifdef __cplusplus
199201
} // ~extern "C"

system/include/emscripten/websocket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extern "C" {
2323
EMSCRIPTEN_RESULT emscripten_websocket_get_ready_state(EMSCRIPTEN_WEBSOCKET_T socket, unsigned short *readyState __attribute__((nonnull)));
2424

2525
// Returns the WebSocket.bufferedAmount field into bufferedAmount. bufferedAmount must not be a null pointer.
26-
EMSCRIPTEN_RESULT emscripten_websocket_get_buffered_amount(EMSCRIPTEN_WEBSOCKET_T socket, unsigned long long *bufferedAmount __attribute__((nonnull)));
26+
EMSCRIPTEN_RESULT emscripten_websocket_get_buffered_amount(EMSCRIPTEN_WEBSOCKET_T socket, size_t *bufferedAmount __attribute__((nonnull)));
2727

2828
// Writes the WebSocket.url field as a UTF-8 string to the memory area pointed by url. The memory area must contain at least urlLength bytes of free space. If this memory area cannot
2929
// fit the url string, it will be truncated. Call emscripten_websocket_get_url_length() to determine how large memory area will be required to store the url.

0 commit comments

Comments
 (0)