shithub: patch

Download patch

ref: ae2b94dda420756baca88a6ef97a1b8ad904670e
parent: 26fa176792ed34ca22c3d605e14328470b88c769
author: qwx <qwx@sciops.net>
date: Sun Oct 27 16:51:01 EDT 2024

update npe tweaks, remove shitty clocks patch

--- a/npe-clock
+++ /dev/null
@@ -1,158 +1,0 @@
-diff c653369e862d2b2235133cfcb0391bc4809ce4b1 uncommitted
---- /dev/null
-+++ b/include/npe/sys/times.h
-@@ -1,0 +1,29 @@
-+#ifndef _npe_sys_times_h_
-+#define _npe_sys_times_h_
-+
-+#include <npe.h>
-+#include <time.h>
-+
-+#ifndef _CLOCK_T
-+#define _CLOCK_T
-+typedef long clock_t;
-+#endif
-+
-+struct tms {
-+	clock_t	tms_utime;
-+	clock_t	tms_stime;
-+	clock_t	tms_cutime;
-+	clock_t	tms_cstime;
-+};
-+
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-+
-+clock_t times2pe(struct tms *);
-+
-+#ifdef __cplusplus
-+}
-+#endif
-+
-+#endif
---- a/include/npe/time.h
-+++ b/include/npe/time.h
-@@ -3,7 +3,21 @@
- 
- #include <npe.h>
- 
-+#include <stddef.h>
-+
-+#define CLOCKS_PER_SEC 1000
-+
-+/* obsolsecent, but required */
-+#define CLK_TCK CLOCKS_PER_SEC
-+
-+#ifndef _CLOCK_T
-+#define _CLOCK_T
-+typedef long clock_t;
-+#endif
-+#ifndef _TIME_T
-+#define _TIME_T
- typedef long time_t;
-+#endif
- 
- struct tm {
- 	int tm_sec;
-@@ -19,6 +33,7 @@
- 
- #include <sys/time.h>
- 
-+clock_t clock(void);
- #define localtime npe_localtime
- struct tm *npe_localtime(time_t *timep);
- #define gmtime npe_gmtime
---- /dev/null
-+++ b/libnpe/clock.c
-@@ -1,0 +1,12 @@
-+#include <time.h>
-+#include <sys/times.h>
-+
-+clock_t
-+clock(void)
-+{
-+	struct tms t;
-+
-+	if(times2pe(&t) == (clock_t)-1)
-+		return (clock_t)-1;
-+	return t.tms_utime+t.tms_stime;
-+}
---- a/libnpe/mkfile
-+++ b/libnpe/mkfile
-@@ -11,6 +11,7 @@
- OFILES=\
- 	_main.$O\
- 	_npe.$O\
-+	clock.$O\
- 	closedir.$O\
- 	dirfd.$O\
- 	exp2.$O\
---- /dev/null
-+++ b/libnpe/times.c
-@@ -1,0 +1,65 @@
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <fcntl.h>
-+#include <sys/times.h>
-+#include <unistd.h>
-+#include <errno.h>
-+#include <string.h>
-+#include <stdlib.h>
-+
-+static
-+char*
-+skip(char *p)
-+{
-+
-+	while(*p == ' ')
-+		p++;
-+	while(*p != ' ' && *p != 0)
-+		p++;
-+	return p;
-+}
-+
-+static clock_t
-+times_(struct tms *buf)
-+{
-+	char b[200], *p;
-+	int f;
-+	unsigned long r;
-+
-+	memset(b, 0, sizeof(b));
-+	f = open("/dev/cputime", O_RDONLY);
-+	if(f >= 0) {
-+		lseek(f, SEEK_SET, 0);
-+		read(f, b, sizeof(b));
-+		close(f);
-+	}
-+	p = b;
-+	if(buf)
-+		buf->tms_utime = atol(p);
-+	p = skip(p);
-+	if(buf)
-+		buf->tms_stime = atol(p);
-+	p = skip(p);
-+	r = atol(p);
-+	if(buf){
-+		p = skip(p);
-+		buf->tms_cutime = atol(p);
-+		p = skip(p);
-+		buf->tms_cstime = atol(p);
-+	}
-+	return r;
-+}
-+
-+clock_t
-+times2pe(struct tms *buf)
-+{
-+	long t[4];
-+	clock_t r;
-+
-+	times(&t):
-+	buf->tms_utime = t[0];
-+	buf->tms_stime = t[1];
-+	buf->tms_cutime = t[2];
-+	buf->tms_cstime = t[3];
-+	return 
-+}
--- a/npe-modhacks
+++ b/npe-modhacks
@@ -1,4 +1,4 @@
-diff 7a8cd4cb0b312e13a88d4d3175a839a2536ee4e3 uncommitted
+diff b699be1156cb41be910dadb3c8a6df0bea12bf67 uncommitted
 --- a/include/npe/SDL2/SDL_keycode.h
 +++ b/include/npe/SDL2/SDL_keycode.h
 @@ -88,15 +88,18 @@
@@ -50,7 +50,7 @@
  	KMOD_CTRL = KMOD_LCTRL|KMOD_RCTRL,
 --- a/include/npe/SDL2/SDL_scancode.h
 +++ b/include/npe/SDL2/SDL_scancode.h
-@@ -110,6 +110,7 @@
+@@ -114,6 +114,7 @@
  	SDL_SCANCODE_MUTE = 0x7f,
  	SDL_SCANCODE_VOLUMEUP,
  	SDL_SCANCODE_VOLUMEDOWN,
@@ -60,7 +60,7 @@
  	SDL_SCANCODE_LSHIFT,
 --- a/libnpe_sdl2/events.c
 +++ b/libnpe_sdl2/events.c
-@@ -246,6 +246,12 @@
+@@ -268,6 +268,12 @@
  	if(r == Kalt) return SDL_SCANCODE_LALT;
  	if(r == Kmod4) return SDL_SCANCODE_LGUI;
  	if(r == Kaltgr) return SDL_SCANCODE_RALT;
@@ -73,16 +73,24 @@
  
  	if(r >= (KF|1) && r <= (KF|12)) return SDL_SCANCODE_F1 + r - (KF|1);
  
-@@ -284,7 +290,7 @@
+@@ -323,7 +329,7 @@
  kbdproc(void *)
  {
  	char buf[128], buf2[128], *s;
 -	int kfd, n, kbin, t;
 +	int kfd, n, kbin, t, ign;
- 	Rune r, o;
+ 	Rune r, scan, o;
  
  	threadsetname("kbdproc");
-@@ -312,8 +318,12 @@
+@@ -335,6 +341,7 @@
+ 	buf2[1] = 0;
+ 	buf[0] = 0;
+ 	kmod = 0;
++	ign = 0;
+ 	for(;;){
+ 		if(buf[0] != 0){
+ 			n = strlen(buf)+1;
+@@ -351,8 +358,12 @@
  		switch(buf[0]){
  		case 'c':
  			if(chartorune(&r, buf+1) > 0 && r != Runeerror){
@@ -97,7 +105,7 @@
  				send(salt[Ckey].c, &o);
  				send(salt[Ckeytype].c, &t);
  				t = Rrepeat;
-@@ -332,8 +342,10 @@
+@@ -375,8 +386,10 @@
  						/* FIXME: does this work in both native AND drawterm? */
  						write(kbin, "\x46", 1);
  						kmod |= KMOD_LALT;
@@ -109,7 +117,7 @@
  					else if(r == Kctl)
  						kmod |= KMOD_LCTRL;
  					else if(r == Kaltgr)
-@@ -340,14 +352,21 @@
+@@ -383,14 +396,21 @@
  						kmod |= KMOD_RALT;
  					else if(r == Kmod4)
  						kmod |= KMOD_LGUI;
@@ -131,7 +139,7 @@
  				}
  			}
  			break;
-@@ -361,12 +380,23 @@
+@@ -408,12 +428,23 @@
  						kmod &= ~KMOD_LALT;
  					else if(r == Kshift)
  						kmod &= ~KMOD_LSHIFT;