Browse Source

Switched to Tup, conformed to Cstd

master
dirkson 5 months ago
parent
commit
b9b9ea2f1c
5 changed files with 109 additions and 5 deletions
  1. +27
    -0
      .gitignore
  2. +69
    -0
      Tupfile
  3. +0
    -3
      build
  4. +0
    -0
      src/dict.c
  5. +13
    -2
      src/kbd.c

+ 27
- 0
.gitignore View File

@@ -53,3 +53,30 @@ Module.symvers
Mkfile.old
dkms.conf

# ---> Vim
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~


# Build framework
bin/
lib/
.tup/
build-*
tup/


+ 69
- 0
Tupfile View File

@@ -0,0 +1,69 @@
CFLAGS = -std=c99 -Werror -Wall -Wpedantic
CFLAGS += -D_XOPEN_SOURCE=700
ifndef DISABLE_SSE
CFLAGS += -msse -msse2 -msse3
endif
#-D_GNU_SOURCE
#HEADERS = inc/parasol.h

ifdef DEBUG
CFLAGS += -Og
CFLAGS += -ggdb3
CFLAGS += -Db_sanitize=address
else
CFLAGS += -O3
CFLAGS += -flto
endif

ifdef CC
CC = @(TARGET)@(CC)
else
CC = gcc
endif

ifdef PKGCONFIG_DIR
PKGCONFIG = PKG_CONFIG_PATH=@(PKGCONFIG_DIR) PKG_CONFIG_LIBDIR=@(PKGCONFIG_DIR) pkg-config
else
PKGCONFIG = @(TARGET)pkg-config
endif

# Compilation binary dependencies - If the binary changes, we rebuild
# Normally tup needs suid to do this. This is an attempt to do this without that.
: |> ^ cksum cc ^ cksum `which $(CC)` > %o |> tup/cc.sum
: |> ^ cksum ar ^ cksum `which @(TARGET)ar` > %o |> tup/ar.sum
: |> ^ cksum ld ^ cksum `which @(TARGET)ld` > %o |> tup/ld.sum
: |> ^ cksum pkg-config ^ cksum `which $(PKGCONFIG)` > %o |> tup/pkg-config.sum

ifndef LD
LDFLAGS += -fuse-ld=gold -fuse-linker-plugin -fno-fat-lto-objects
else
LDFLAGS += @(LD)
endif

#CFLAGS += -Iinc
#CFLAGS += `$(PKGCONFIG) --cflags libuv`

ifndef SHAREDLIBS
LDFLAGS += -static
endif

#LDFLAGS += `@(TARGET)pkg-config --libs libuv`

# Macros
!cc-obj = | <header> tup/cc.sum |> ^ CC %f^ $(CC) $(CFLAGS) -c %f -o %o |>
!cc-bin = | <header> tup/cc.sum |> ^ CC %f^ $(CC) $(CFLAGS) %f -o %o $(LDFLAGS) |>
!ar = | tup/ar.sum |> ^ AR %f^ @(TARGET)ar rcs %o %f |>

#:foreach src/*.c |> !cc-obj |> obj/%B.o

:src/kbd.c |> !cc-bin |> bin/kbd

#:foreach src/dict/*.c |> !cc-obj |> obj/dict/%B.o

:src/dict.c |> !cc-bin |> bin/dict

#:foreach src/examples/*.c |> !cc-bin |> bin/%B


#Copy over the include file to any variants
#:foreach inc/*.h |> !tup_preserve |> inc/%b | <header>

+ 0
- 3
build View File

@@ -1,3 +0,0 @@
#!/bin/bash
ccache cc src/kbd.c -Isrc -o kbd
ccache cc src/dicts.c

src/dicts.c → src/dict.c View File


+ 13
- 2
src/kbd.c View File

@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include <errno.h>
#include <linux/input.h>
@@ -15,6 +16,15 @@

#define kbd_err(str) { perror("kbderr: "str); exit(EXIT_FAILURE); }

void sleep_us(unsigned long microseconds)
{
struct timespec ts;
ts.tv_sec = microseconds / 1000000; // whole seconds
ts.tv_nsec = (microseconds % 1000000) * 1000; // remainder, in nanoseconds
nanosleep(&ts, NULL);
}


typedef struct kbd_state_t
{
int key[16];
@@ -242,7 +252,7 @@ void kbd_init(int *letters, int *fdo, int *fdi, int *ftty, char *str, kbd_chord_

//input
*fdi = open(str, O_RDONLY);
if(fdi < 0) kbd_err("failed to open device");
if(*fdi < 0) kbd_err("failed to open device");

/*
memset(afdi, 0, sizeof(struct input_event));
@@ -260,7 +270,8 @@ void kbd_init(int *letters, int *fdo, int *fdi, int *ftty, char *str, kbd_chord_

//We need time for the user's finger to come off the enter button
//This also doubles at time for linux to notice the new ui device
usleep(100000);
sleep_us(100000);

if(ioctl(*fdi, EVIOCGRAB, 1) < 0) kbd_err("eviocgrab failed");
}



Loading…
Cancel
Save