Skip to content

Commit f0bd84d

Browse files
committed
17_5 cleanup
1 parent 25ee05e commit f0bd84d

File tree

6 files changed

+208
-271
lines changed

6 files changed

+208
-271
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- REL_17_5_WASM/src/backend/storage/ipc/sinvaladt.c
2+
+++ pglite-REL_17_5_WASM/src/backend/storage/ipc/sinvaladt.c
3+
@@ -289,6 +289,7 @@
4+
*/
5+
LWLockAcquire(SInvalWriteLock, LW_EXCLUSIVE);
6+
#if defined(__EMSCRIPTEN__) || defined(__wasi__)
7+
+ (void)oldPid;
8+
#else
9+
oldPid = stateP->procPid;
10+
if (oldPid != 0)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--- REL_17_5_WASM/src/interfaces/libpq/fe-auth.c
2+
+++ pglite-REL_17_5_WASM/src/interfaces/libpq/fe-auth.c
3+
@@ -1169,6 +1169,7 @@
4+
pg_fe_getusername(uid_t user_id, PQExpBuffer errorMessage)
5+
{
6+
char *result = NULL;
7+
+#if !defined(__EMSCRIPTEN__) && !defined(__wasi__)
8+
const char *name = NULL;
9+
10+
#ifdef WIN32
11+
@@ -1192,7 +1193,9 @@
12+
else if (errorMessage)
13+
appendPQExpBuffer(errorMessage, "%s\n", pwdbuf);
14+
#endif
15+
-
16+
+#else
17+
+ const char *name = getenv("PGUSER");
18+
+#endif
19+
if (name)
20+
{
21+
result = strdup(name);

patches-REL_17_5_WASM/postgresql-wasi/src-include-port-wasi.h.diff

Lines changed: 5 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- REL_17_5_WASM/src/include/port/wasi.h
22
+++ pglite-REL_17_5_WASM/src/include/port/wasi.h
3-
@@ -1,17 +1,336 @@
3+
@@ -1,17 +1,229 @@
44
-/* src/include/port/{wasi/emscripten}.h */
55
+#pragma once
66

@@ -54,70 +54,6 @@
5454
+ return -1;
5555
+}
5656
+
57-
+/*
58-
+struct __wasi_addrinfo_t{
59-
+ int32_t ai_flags;
60-
+ int32_t ai_family;
61-
+ int32_t ai_socktype;
62-
+ int32_t ai_protocol;
63-
+ __wasi_size_t ai_addrlen;
64-
+ __wasi_address_t* ai_addr;
65-
+ //__wasi_size_t ai_canonname_len;
66-
+ uint32_t ai_canonname;
67-
+ struct __wasi_addrinfo_t** ai_next;
68-
+};
69-
+*/
70-
+
71-
+#include <arpa/inet.h> // for inet_pton
72-
+#include <sys/types.h>
73-
+#include <sys/socket.h>
74-
+#include <netdb.h>
75-
+
76-
+/* extern one is not valid in wasip2
77-
+extern int getaddrinfo(const char *restrict node,
78-
+ const char *restrict service,
79-
+ const struct addrinfo *restrict hints,
80-
+ struct addrinfo **restrict res);
81-
+*/
82-
+
83-
+
84-
+/*
85-
+static int getaddrinfo(const char *hostname, const char *service,
86-
+ const struct addrinfo *hints, struct addrinfo **res) {
87-
+ struct addrinfo *result = malloc(sizeof(struct addrinfo));
88-
+ if (!result) return EAI_MEMORY;
89-
+
90-
+ memset(result, 0, sizeof(struct addrinfo));
91-
+ result->ai_family = AF_INET;
92-
+ result->ai_socktype = SOCK_STREAM;
93-
+ result->ai_protocol = IPPROTO_TCP;
94-
+
95-
+ struct sockaddr_in *addr = malloc(sizeof(struct sockaddr_in));
96-
+ if (!addr) {
97-
+ free(result);
98-
+ return EAI_MEMORY;
99-
+ }
100-
+
101-
+ addr->sin_family = AF_INET;
102-
+ addr->sin_port = htons(atoi(service));
103-
+ if (inet_pton(AF_INET, hostname, &(addr->sin_addr)) <= 0) {
104-
+ free(result);
105-
+ free(addr);
106-
+ return EAI_FAIL;
107-
+ }
108-
+
109-
+ result->ai_addr = (struct sockaddr *)addr;
110-
+ result->ai_addrlen = sizeof(struct sockaddr_in);
111-
+ result->ai_next = NULL;
112-
+
113-
+ *res = result;
114-
+ return 0;
115-
+}
116-
+
117-
+*/
118-
+
119-
+
120-
+
12157
+// ============= signal ==============
12258
+
12359
+#define SA_RESTART 4
@@ -157,8 +93,6 @@
15793
+}
15894
+
15995
+
160-
+
161-
+
16296
+// WIP: semaphores
16397
+// https://github.com/bytecodealliance/wasm-micro-runtime/issues/3054
16498
+#include <sys/sem.h>
@@ -245,25 +179,10 @@
245179
+
246180
+// ====================================================
247181
+
248-
+/*
249-
+#include <setjmp.h>
250-
+
251-
+static int
252-
+sigsetjmp(sigjmp_buf env, int savesigs) {
253-
+// puts("# 201: sigsetjmp");
254-
+ return 0;
255-
+}
256-
+
257-
+static void
258-
+siglongjmp(sigjmp_buf env, int val) {
259-
+ puts("# 207: siglongjmp");
260-
+}
261-
+*/
262-
+
263-
+
264182
+// WIP :
265183
+
266184
+#include <sys/mman.h>
185+
+
267186
+#if defined(PYDK)
268187
+extern int shm_open(const char *name, int oflag, mode_t mode);
269188
+extern int shm_unlink(const char *name);
@@ -274,15 +193,15 @@
274193
+ int fd;
275194
+ snprintf(tmpnam, 128, "/tmp%s", name);
276195
+ fd=fileno(fopen(tmpnam, "w+"));
277-
+ fprintf(stderr, "# 212: shm_open(%s) => %d\n", tmpnam, fd);
196+
+ fprintf(stderr, "# 186: shm_open(%s) => %d\n", tmpnam, fd);
278197
+ return fd;
279198
+}
280199
+
281200
+static int
282201
+shm_unlink(const char *name) {
283202
+ char tmpnam[128];
284203
+ snprintf(tmpnam, 128, "/tmp%s", name);
285-
+ fprintf(stderr, "# 220: shm_unlink(%s) STUB\n", tmpnam);
204+
+ fprintf(stderr, "# 194: shm_unlink(%s) STUB\n", tmpnam);
286205
+ return remove(tmpnam); // -1
287206
+}
288207
+
@@ -293,7 +212,7 @@
293212
+
294213
+static void
295214
+tzset(void) {
296-
+ puts("# 241: tzset(void) STUB");
215+
+ puts("# 205: tzset(void) STUB");
297216
+}
298217
+
299218
+#if defined(PG_INITDB) || defined(FE_UTILS_PRINT) || defined(PG_DUMP_PARALLEL)
@@ -303,22 +222,6 @@
303222
+#endif
304223
+
305224
+
306-
+
307-
+
308-
+// TODO: socket here
309-
+// ==================================================================
310-
+
311-
+#include <sys/socket.h>
312-
+
313-
+//extern ssize_t sdk_recv(int sockfd, void *buf, size_t len, int flags);
314-
+//extern ssize_t recvfrom(int socket, void *buffer, size_t length, int flags, void *address, socklen_t *address_len);
315-
+
316-
+//extern ssize_t sdk_send(int sockfd, const void *buf, size_t len, int flags);
317-
+//extern ssize_t sendto(int sockfd, const void *buf, size_t len, int flags, void *dest_addr, socklen_t addrlen);
318-
+
319-
+
320-
+
321-
+
322225
+static int
323226
+listen(int sockfd, int backlog) {
324227
+ return 0;
@@ -329,19 +232,9 @@
329232
+ return NULL;
330233
+}
331234
+
332-
+//#define pthread_mutex_lock(mut) sdk_pthread_mutex_lock(mut)
333-
+//extern int sdk_pthread_mutex_lock(void *mutex);
334-
+
335-
+/*
336-
+ int pthread_mutex_lock(pthread_mutex_t *mutex);
337-
+ int pthread_mutex_trylock(pthread_mutex_t *mutex);
338-
+ int pthread_mutex_unlock(pthread_mutex_t *mutex);
339-
+*/
340-
+
341235
+#endif // __wasi__p2
342236
+
343237
+#endif // I_WASI
344-
+
345238

346239

347240
-#endif // I_WASM

0 commit comments

Comments
 (0)