[EGIT] [legacy-imlib2] 01/05: Loaders: Debug macro cleanups
This is an automated email from the git hooks/post-receive script. git pushed a commit to branch master in repository legacy-imlib2. View the commit online. commit 495fb5e6f800ed8d171a18510f3603d5aa6a7932 Author: Kim Woelders AuthorDate: Sat Jan 28 14:09:44 2023 +0100 Loaders: Debug macro cleanups --- src/lib/Imlib2_Loader.h | 10 ++ src/modules/loaders/loader_ani.c | 6 -- src/modules/loaders/loader_bmp.c | 10 +- src/modules/loaders/loader_tiff.c | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/lib/Imlib2_Loader.h b/src/lib/Imlib2_Loader.h index 6bd4c36..63f8637 100644 --- a/src/lib/Imlib2_Loader.h +++ b/src/lib/Imlib2_Loader.h @@ -69,15 +69,16 @@ typedef struct _ImlibImage ImlibImage; #if IMLIB2_DEBUG -#define DC(M, fmt...) if (__imlib_debug & M) __imlib_printf(DBG_PFX, fmt) +#define DC(PFX, M, fmt...) if (__imlib_debug & M) __imlib_printf(PFX, fmt) #define DBG_FILE 0x0001 #define DBG_LOAD 0x0002 #define DBG_LDR 0x0004 #define DBG_LDR2 0x0008 -#define D(fmt...) DC(DBG_LDR, fmt) -#define DL(fmt...) DC(DBG_LDR2, fmt) +#define D(fmt...) DC(DBG_PFX, DBG_LDR, fmt) +#define Dx(fmt...) DC(NULL, DBG_LDR, fmt) +#define DL(fmt...) DC(DBG_PFX, DBG_LDR2, fmt) extern unsigned int __imlib_debug; @@ -87,8 +88,9 @@ unsigned int__imlib_time_us(void); #else -#define D(fmt...) #define DC(fmt...) +#define D(fmt...) +#define Dx(fmt...) #define DL(fmt...) #endif /* IMLIB2_DEBUG */ diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c index 00eadfc..9bb344e 100644 --- a/src/modules/loaders/loader_ani.c +++ b/src/modules/loaders/loader_ani.c @@ -8,12 +8,6 @@ #include "config.h" #include "Imlib2_Loader.h" -#if IMLIB2_DEBUG -#define Dx(fmt...) if (__imlib_debug & DBG_LDR) __imlib_printf(NULL, fmt) -#else -#define Dx(fmt...) -#endif - #define DBG_PFX "LDR-ani" #define T(a,b,c,d) ((a << 0) | (b << 8) | (c << 16) | (d << 24)) diff --git a/src/modules/loaders/loader_bmp.c b/src/modules/loaders/loader_bmp.c index 9838fdd..0ace8b6 100644 --- a/src/modules/loaders/loader_bmp.c +++ b/src/modules/loaders/loader_bmp.c @@ -11,7 +11,7 @@ #include "Imlib2_Loader.h" #define DBG_PFX "LDR-bmp" -#define Dx(fmt...) +#define DD(fmt...) static const char *const _formats[] = { "bmp" }; @@ -459,7 +459,7 @@ _load(ImlibImage * im, int load_data) byte1 = buffer_ptr[0]; byte2 = buffer_ptr[1]; buffer_ptr += 2; - Dx("%3d %3d: %02x %02x (%d %d)\n", + DD("%3d %3d: %02x %02x (%d %d)\n", x, y, byte1, byte2, byte2 >> 4, byte2 & 0xf); if (byte1) { @@ -520,7 +520,7 @@ _load(ImlibImage * im, int load_data) for (j = 0; j < l; j++) { byte = *buffer_ptr++; - Dx("%3d %3d: %d/%d: %2d %2d\n", + DD("%3d %3d: %d/%d: %2d %2d\n", x, y, j, l, byte >> 4, byte & 0xf); *ptr++ = argbCmap[byte >> 4]; if (++j < l) @@ -583,7 +583,7 @@ _load(ImlibImage * im, int load_data) byte1 = buffer_ptr[0]; byte2 = buffer_ptr[1]; buffer_ptr += 2; - Dx("%3d %3d: %02x %02x\n", x, y, byte1, byte2); + DD("%3d %3d: %02x %02x\n", x, y, byte1, byte2); if (byte1) { pixel = argbCmap[byte2]; @@ -632,7 +632,7 @@ _load(ImlibImage * im, int load_data) for (j = 0; j < l; j++) { byte = *buffer_ptr++; - Dx("%3d %3d: %d/%d: %2d\n", + DD("%3d %3d: %d/%d: %2d\n", x, y, j, l, byte); *ptr++ = argbCmap[byte]; } diff --git a/src/modules/loaders/loader_tiff.c b/src/modules/loaders/loader_tiff.c index c9a4ec4..00ca8cb 100644 --- a/src/modules/loaders/loader_tiff.c +++ b/src/modules/loaders/loader_tiff.c @@ -8,7 +8,7 @@ static const char *const _formats[] = { "tiff", "tif" }; -#define DD(fmt...) DC(0x80, fmt) +#define DD(fmt...) DC(DBG_PFX, 0x80, fmt) static struct { const unsigned char *data, *dptr; -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[EGIT] [legacy-imlib2] 04/05: autofoo: Add __PACKED__ for optional struct packing
This is an automated email from the git hooks/post-receive script. git pushed a commit to branch master in repository legacy-imlib2. View the commit online. commit 9222dad42dcc50a931f04cb46bfb11c7c5a5c4db Author: Kim Woelders AuthorDate: Sat Jan 28 11:04:30 2023 +0100 autofoo: Add __PACKED__ for optional struct packing --- configure.ac | 2 ++ m4/ec_packing.m4 | 23 +++ 2 files changed, 25 insertions(+) diff --git a/configure.ac b/configure.ac index 791f44d..2b8b78f 100644 --- a/configure.ac +++ b/configure.ac @@ -259,6 +259,7 @@ AM_CONDITIONAL(BUILD_DOC, test "$enable_doc_build" = "yes") EC_C_WARNINGS() EC_C_VISIBILITY(yes) +EC_C_PACKING() EC_C_ASAN() VERSION_MAJOR=`echo $VERSION | awk -F. '{print $1}'` @@ -328,6 +329,7 @@ echo echo "Include filters...: $enable_filters" echo "Include text functions: $enable_text" echo "Use visibility hiding.: $enable_visibility_hiding" +echo "Use struct packing: $enable_packing" echo echo "Installation path.: $prefix" echo diff --git a/m4/ec_packing.m4 b/m4/ec_packing.m4 new file mode 100644 index 000..ec9699f --- /dev/null +++ b/m4/ec_packing.m4 @@ -0,0 +1,23 @@ +dnl Copyright (C) 2023 Kim Woelders +dnl This code is public domain and can be freely used or copied. + +dnl Macro to define __PACKED__ if supported and --enable-packing is given + +dnl Usage: EC_C_PACKING() + +AC_DEFUN([EC_C_PACKING], [ + AC_ARG_ENABLE([packing], +[AS_HELP_STRING([--enable-packing], +[enable packing structures for unaligned access @<:@default=no@:>@])],, +[enable_packing=no]) + + if test "x$enable_packing" = "xyes"; then +if test -n "$GCC"; then + AC_DEFINE(__PACKED__, __attribute__((packed)), [Use struct packing for unaligned access]) +else + AC_MSG_ERROR([Struct packing was requested but no method is known]) +fi + else +AC_DEFINE(__PACKED__, , [Not using struct packing for unaligned access]) + fi +]) -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[EGIT] [legacy-imlib2] 03/05: Loaders: Avoid cast-align warnings with -Wcast-align=strict
This is an automated email from the git hooks/post-receive script. git pushed a commit to branch master in repository legacy-imlib2. View the commit online. commit d27354926a3dab93584b4c1988995eea512d6fe5 Author: Kim Woelders AuthorDate: Fri Jan 27 08:51:54 2023 +0100 Loaders: Avoid cast-align warnings with -Wcast-align=strict --- src/lib/Imlib2_Loader.h | 2 ++ src/modules/loaders/loader_ani.c | 12 src/modules/loaders/loader_bmp.c | 4 ++-- src/modules/loaders/loader_png.c | 9 ++--- src/modules/loaders/loader_tga.c | 3 ++- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/lib/Imlib2_Loader.h b/src/lib/Imlib2_Loader.h index 63f8637..ec0c36e 100644 --- a/src/lib/Imlib2_Loader.h +++ b/src/lib/Imlib2_Loader.h @@ -224,4 +224,6 @@ int decompress_load(ImlibImage * im, int load_data, #define QUIT_WITH_RC(_err) { rc = _err; goto quit; } +#define PCAST(T, p) ((T)(const void *)(p)) + #endif /* IMLIB2_LOADER_H */ diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c index 034ba97..b436f46 100644 --- a/src/modules/loaders/loader_ani.c +++ b/src/modules/loaders/loader_ani.c @@ -28,7 +28,8 @@ static const char *const _formats[] = { "ani" }; typedef struct { unsigned char nest; int nframes, nfsteps; - uint32_t *rates, *seq; + const uint32_t *rates; + const uint32_t *seq; } riff_ctx_t; typedef struct { @@ -119,7 +120,8 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata, break; } -chunk = (const ani_chunk_t *)fptr; +chunk = PCAST(const ani_chunk_t *, fptr); + type = SWAP_LE_32(chunk->hdr.type); size = SWAP_LE_32(chunk->hdr.size); @@ -202,7 +204,8 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata, pf->frame_delay = (1000 * SWAP_LE_32(AH.rate)) / 60; break; case RIFF_TYPE_rate: - ctx->rates = (uint32_t *) (fptr + 8); + ctx->rates = PCAST(const uint32_t *, fptr + 8); + if ((int)size != 4 * ctx->nfsteps) { D("rate chunk size mismatch: %d != %d\n", size, @@ -216,7 +219,8 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata, Dx("\n"); break; case RIFF_TYPE_seq: - ctx->seq = (uint32_t *) (fptr + 8); + ctx->seq = PCAST(const uint32_t *, fptr + 8); + if ((int)size != 4 * ctx->nfsteps) { D("seq chunk size mismatch: %d != %d\n", size, diff --git a/src/modules/loaders/loader_bmp.c b/src/modules/loaders/loader_bmp.c index 0ace8b6..c47363a 100644 --- a/src/modules/loaders/loader_bmp.c +++ b/src/modules/loaders/loader_bmp.c @@ -681,7 +681,7 @@ _load(ImlibImage * im, int load_data) { for (x = 0; x < w && buffer_ptr < buffer_end_safe; x++) { - pixel = *(unsigned short *)buffer_ptr; + pixel = *PCAST(const unsigned short *, buffer_ptr); if (im->has_alpha) a = SCALE(a, pixel); @@ -730,7 +730,7 @@ _load(ImlibImage * im, int load_data) { for (x = 0; x < w && buffer_ptr < buffer_end_safe; x++) { - pixel = *(unsigned int *)buffer_ptr; + pixel = *PCAST(const unsigned int *, buffer_ptr); if (im->has_alpha) a = SCALE(a, pixel); diff --git a/src/modules/loaders/loader_png.c b/src/modules/loaders/loader_png.c index 9e58273..34c5b9b 100644 --- a/src/modules/loaders/loader_png.c +++ b/src/modules/loaders/loader_png.c @@ -244,7 +244,8 @@ row_callback(png_struct * png_ptr, png_byte * new_row, PNG_PASS_COLS(im->w, pass), PNG_PASS_ROWS(im->h, pass)); y = y0 + dy * row_num; -sptr = (const uint32_t *)new_row; /* Assuming aligned */ +sptr = PCAST(const uint32_t *, new_row);/* Assuming aligned */ + dptr = im->data + y * im->w; for (x = x0; x < im->w; x += dx) { @@ -341,7 +342,8 @@ _load(ImlibImage * im, int load_data) for (ic = 0;; ic++, fptr += 8 + len + 4) { -chunk = (const png_chunk_t *)fptr; +chunk = PCAST(const png_chunk_t *, fptr); + len = htonl(chunk->hdr.len); D("Scan %3d: %06lx: %6d: %.4s: ", ic, fptr - (unsigned char *)im->fi->fdata, len, chunk->hdr.name); @@ -429,7 +431,8 @@ _load(ImlibImage * im, int load_data) for (ic = 0;; ic++, fptr += 8 + len + 4) { -chunk = (const png_chunk_t *)fptr; +chunk = PCAST(const png_chunk_t *, fptr); + len = htonl(chunk->hdr.len); D("Chunk %3d: %06lx: %6d: %.4s: ", ic, fptr - (unsigned char *)im->fi->fdata, len, chunk->hdr.name); diff --git a/src/modules/loaders/loader_tga.c
[EGIT] [legacy-imlib2] 02/05: ANI loader: Use struct to access chunk data
This is an automated email from the git hooks/post-receive script. git pushed a commit to branch master in repository legacy-imlib2. View the commit online. commit 6337c54d30ab58cc9160b4807b924f4386a17129 Author: Kim Woelders AuthorDate: Sat Jan 28 09:52:08 2023 +0100 ANI loader: Use struct to access chunk data --- src/modules/loaders/loader_ani.c | 57 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c index 9bb344e..034ba97 100644 --- a/src/modules/loaders/loader_ani.c +++ b/src/modules/loaders/loader_ani.c @@ -32,16 +32,27 @@ typedef struct { } riff_ctx_t; typedef struct { - uint32_tsize;// Size of chunk data (=36) - uint32_tframes; // Number of frames in file - uint32_tsteps; // Number of steps in animation sequence - uint32_twidth; // Image width (raw data only?) - uint32_theight; // Image height (raw data only?) - uint32_tbpp; // Bits per pixel (raw data only?) - uint32_tplanes; // N. planes (raw data only?) - uint32_trate;// Default rate in 1/60s - uint32_tflags; // Flags: ANIH_FLAG_... -} anih_data_t; + struct { + uint32_ttype; // Chunk type + uint32_tsize; // Chunk size + } hdr; + union { + struct { + uint32_tname; // List name + } list; + struct { + uint32_tsize; // Size of chunk data (=36) + uint32_tframes;// Number of frames in file + uint32_tsteps; // Number of steps in animation sequence + uint32_twidth; // Image width (raw data only?) + uint32_theight;// Image height (raw data only?) + uint32_tbpp; // Bits per pixel (raw data only?) + uint32_tplanes;// N. planes (raw data only?) + uint32_trate; // Default rate in 1/60s + uint32_tflags; // Flags: ANIH_FLAG_... + } anih; + }; +} ani_chunk_t; #define ANIH_FLAG_ICO 0x01// Frames are icons or cursors (otherwiwe raw - bmp?) #define ANIH_FLAG_SEQ 0x02// Image contains seq chunk @@ -76,7 +87,6 @@ _load_embedded(ImlibImage * im, int load_data, const char *data, return rc; } -#define LE32(p) (SWAP_LE_32(*((const uint32_t*)(p #define OFFS(p) ((const char*)(p) - (const char*)im->fi->fdata) static int @@ -88,6 +98,7 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata, int size, avail; int fcount, i; ImlibImageFrame*pf; + const ani_chunk_t *chunk; rc = LOAD_FAIL; ctx->nest += 1; @@ -108,8 +119,9 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata, break; } -type = LE32(fptr); -size = LE32(fptr + 4); +chunk = (const ani_chunk_t *)fptr; +type = SWAP_LE_32(chunk->hdr.type); +size = SWAP_LE_32(chunk->hdr.size); D("%5lu: %*s Chunk: %.4s size %u: ", OFFS(fptr), ctx->nest, "", fptr, size); @@ -118,7 +130,8 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata, { Dx("\n"); /* First chunk of file */ - if (type != RIFF_TYPE_RIFF || (LE32(fptr + 8)) != RIFF_NAME_ACON) + if (type != RIFF_TYPE_RIFF || + (SWAP_LE_32(chunk->list.name)) != RIFF_NAME_ACON) return LOAD_FAIL; size = 4; continue; @@ -161,16 +174,16 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata, rc = _load_embedded(im, 1, fptr + 8, size); break; case RIFF_TYPE_anih: -#define AH ((const anih_data_t*)(fptr + 8)) +#define AH (chunk->anih) /**INDENT-OFF**/ Dx("sz=%u nf=%u/%u WxH=%ux%u bc=%u np=%u dr=%u fl=%u\n", - SWAP_LE_32(AH->size), SWAP_LE_32(AH->frames), SWAP_LE_32(AH->steps), - SWAP_LE_32(AH->width), SWAP_LE_32(AH->height), - SWAP_LE_32(AH->bpp), SWAP_LE_32(AH->planes), - SWAP_LE_32(AH->rate), SWAP_LE_32(AH->flags)); + SWAP_LE_32(AH.size), SWAP_LE_32(AH.frames), SWAP_LE_32(AH.steps), + SWAP_LE_32(AH.width), SWAP_LE_32(AH.height), + SWAP_LE_32(AH.bpp), SWAP_LE_32(AH.planes), + SWAP_LE_32(AH.rate), SWAP_LE_32(AH.flags)); /**INDENT-ON**/ - ctx->nframes = SWAP_LE_32(AH->frames); - ctx->nfsteps = SWAP_LE_32(AH->steps); + ctx->nframes = SWAP_LE_32(AH.frames); + ctx->nfsteps = SWAP_LE_32(AH.steps); if (im->frame <= 0) break; if (ctx->nfsteps < ctx->nframes) @@ -186,7 +199,7 @@ _riff_parse(ImlibImage * im, riff_ctx_t * ctx, const char *fdata,
[EGIT] [legacy-imlib2] 05/05: ANI, PNG, TGA loaders: Enable handling of unaligned data
This is an automated email from the git hooks/post-receive script. git pushed a commit to branch master in repository legacy-imlib2. View the commit online. commit 5c226954c114f1ced7027498fd2debd34bea08f2 Author: Kim Woelders AuthorDate: Sat Jan 28 09:35:50 2023 +0100 ANI, PNG, TGA loaders: Enable handling of unaligned data Fixes warnings seen with -fsanitize=undefined when using --enable-packed. --- src/modules/loaders/loader_ani.c | 2 +- src/modules/loaders/loader_png.c | 12 ++-- src/modules/loaders/loader_tga.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/modules/loaders/loader_ani.c b/src/modules/loaders/loader_ani.c index b436f46..cd38236 100644 --- a/src/modules/loaders/loader_ani.c +++ b/src/modules/loaders/loader_ani.c @@ -32,7 +32,7 @@ typedef struct { const uint32_t *seq; } riff_ctx_t; -typedef struct { +typedef struct __PACKED__ { struct { uint32_ttype; // Chunk type uint32_tsize; // Chunk size diff --git a/src/modules/loaders/loader_png.c b/src/modules/loaders/loader_png.c index 34c5b9b..b6536d9 100644 --- a/src/modules/loaders/loader_png.c +++ b/src/modules/loaders/loader_png.c @@ -32,7 +32,7 @@ static const char *const _formats[] = { "png" }; #define mm_check(p) ((const char *)(p) <= (const char *)im->fi->fdata + im->fi->fsize) -typedef struct { +typedef struct __PACKED__ { uint32_tlen; union { uint32_ttype; @@ -41,7 +41,7 @@ typedef struct { } png_chunk_hdr_t; /* IHDR */ -typedef struct { +typedef struct __PACKED__ { uint32_tw; // Width uint32_th; // Height uint8_t depth; // Bit depth (1, 2, 4, 8, or 16) @@ -54,13 +54,13 @@ typedef struct { #define _PNG_IHDR_SIZE (4 + 4 + 13 + 4) /* acTL */ -typedef struct { +typedef struct __PACKED__ { uint32_tnum_frames; // Number of frames uint32_tnum_plays; // Number of times to loop this APNG. 0 indicates infinite looping. } png_actl_t; /* fcTL */ -typedef struct { +typedef struct __PACKED__ { uint32_tframe; // -- // Sequence number of the animation chunk, starting from 0 uint32_tw; // -- // Width of the following frame uint32_th; // -- // Height of the following frame @@ -73,12 +73,12 @@ typedef struct { } png_fctl_t; /* fdAT */ -typedef struct { +typedef struct __PACKED__ { uint32_tframe; // -- // Sequence number of the animation chunk, starting from 0 uint8_t data[]; } png_fdat_t; -typedef struct { +typedef struct __PACKED__ { png_chunk_hdr_t hdr; union { png_ihdr_t ihdr; diff --git a/src/modules/loaders/loader_tga.c b/src/modules/loaders/loader_tga.c index 1f97ba9..03285d4 100644 --- a/src/modules/loaders/loader_tga.c +++ b/src/modules/loaders/loader_tga.c @@ -49,7 +49,7 @@ typedef struct { unsigned char descriptor; } tga_header; -typedef struct { +typedef struct __PACKED__ { unsigned intextensionAreaOffset; unsigned intdeveloperDirectoryOffset; charsignature[16]; -- To stop receiving notification emails like this one, please contact the administrator of this repository.
[E-devel] [Terminology] Cooperative tiling between Terminology and hosted programs
Hi folks, in my mind, Terminology tries to push the boundaries of what's possible with terminal emulators forward. For instance, it has support for embedding videos and images through custom escape sequences. It obviously expects programs will make use of the new Terminology features. It just occurred to me that programas could cooperate with Terminology to make their own custom tiling. For instance, Emacs has the eshell mode where Emacs acts as its own terminal emulator taking care of interpreting ANSI escape sequences and tiling the embedded terminal in its own window all by itself. What if Terminology exposed an env var such as TERMINOLOGY_SOCK=$XDG_RUNTIME_DIR/sock-1234.sock with a path for a UNIX socket so the program (such as Emacs) could open it to cooperate with Terminology? Emacs could open a new pty, spawn the embedded shell, and send a fd to the master end of the new pty back to Terminology. The message should include the position in the screen for the new embedded terminal. Now Terminology would only read from the master end so it can draw the contents of the embedded terminal appropriately in the new tile of the terminal window. Emacs would still get all the input as usual and only send input to the new terminal as it pleases (by writing in the master end of the pty). So, Terminology already decodes ANSI escape sequences and performs tiling of terminal windows. The idea is to let applications reuse this implementation to allow further embedding other interactive programs in their own windows. Thoughts? -- VinÃcius dos Santos Oliveira https://vinipsmaker.github.io/ ___ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel