Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e56fe8b1-6880-a6e9-6f4f-e83a976cacde@mirbsd.de>
Date: Thu, 19 Nov 2026 04:17:17 +0100 (CET)
From: Thorsten Glaser <tg@...bsd.de>
To: musl@...ts.openwall.com
Subject: Re: [PATCH v1 10/18] fts: drop aligned statp alloc support

On Wed, 18 Nov 2026, Rich Felker wrote:

>> > interface or internal to musl. Hopefully this isn't something callers
>> > can depend on and it can just be fixed to use a real FAM.

>I don't see where the fts_name[1] is fixed. It needs to be fts_name[]

Yes, fts is a FAM API.

Not sure what the requirements on toolchain in musl re. FAM support
are; it’s shaky especially for C++ compilers.

In my abstracting-these-things-away headers, I’m using (simplified)
this so far (macro intended to be used in these struct definitions):

#if defined(MBSDCC_H_NO_FAM)
#  define mbccFAMslot(type,memb)  type memb[1] __disable_warning(4820)
#elif defined(__cplusplus)
# ifdef __cpp_flexible_array_members
#  define mbccFAMslot(type,memb)  type memb[]
# elif defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
#  define mbccFAMslot(type,memb)  type memb[0] __disable_warning(4200 4820)
# else
#  define mbccFAMslot(type,memb)  type memb[1] __disable_warning(4820)
# endif
#elif (defined(__STDC_VERSION__) && ((__STDC_VERSION__) >= 199901L))
#  define mbccFAMslot(type,memb)  type memb[]
#elif defined(__GNUC__)
#  define mbccFAMslot(type,memb)  type memb[0] __disable_warning(4200 4820)
#else
#  define mbccFAMslot(type,memb)  type memb[1] __disable_warning(4820) /* SOL */
#endif

(where __disable_warning is used for MSC, Watcom, etc.)

The two cases (one for C++, one for C) where it simply gives up and
resorts to 1-array (unless explicitly requested by the user by defining
the NO_FAM macro) are basically where neither standard nor extension
give us either 0-array or empty-array.

This has seen *some* platform coverage (including in both C and C++ modes
MSVC, OpenWatcom, xlC, modern and antique GCC, SUNWcc (Sun Studio 12.6))
but not yet all the various obscure ones.


And calculation of the size for the alloc, after having been chastised
by someone who also explicitly does not want to be named but is involved
in C: (simplified, the original also checks against SIZE_MAX)

#define mbccFAMsz_i(t,memb,sz)  /*private*/ (size_t)(offsetof(t, memb) + (size_t)sz)
/* compile-time constant */
#define mbccFAMSZ(struc,memb,sz) \
	((size_t)((mbccFAMsz_i(struc, memb, (sz)) > sizeof(struc) ? \
                   mbccFAMsz_i(struc, memb, (sz)) : sizeof(struc))))


So, on the C side, C99 is sufficient, but __cpp_flexible_array_members
is a rather late feature. Of course, this may be still ok for musl…


On the series as a whole: YES PLEASE! Having a high-quality fts
available would help much, less bundling or hacks. It is a cornerstone
of archivers, for example.

bye,
//mirabilos
-- 
“It is inappropriate to require that a time represented as
 seconds since the Epoch precisely represent the number of
 seconds between the referenced time and the Epoch.”
	-- IEEE Std 1003.1b-1993 (POSIX) Section B.2.2.2

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.