9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] Fix assert macro to not break on commas
@ 2023-11-22 23:11 Blue-Maned_Hawk
  2023-11-23  4:20 ` Jacob Moody
  2023-11-26 22:36 ` ori
  0 siblings, 2 replies; 33+ messages in thread
From: Blue-Maned_Hawk @ 2023-11-22 23:11 UTC (permalink / raw)
  To: 9front

This is a pair of patches that changes the assert macro to be variadic, 
allowing expressions with commas in them to be used without needing a 
spare pair of parentheses, and updates the manpage accordingly.
\x1f
diff 04d6a2acecfe4fe44947da8b676f63bcd0f3c0fe uncommitted
--- a/sys/include/libc.h
+++ b/sys/include/libc.h
@@ -3,7 +3,7 @@

  #define	nelem(x)	(sizeof(x)/sizeof((x)[0]))
  #define	offsetof(s, m)	(ulong)(&(((s*)0)->m))
-#define	assert(x)	if(x){}else _assert("x")
+#define	assert(...)	if(__VA_ARGS__){}else _assert("__VA_ARGS__")

  /*
   * mem routines
\x1f
diff 04d6a2acecfe4fe44947da8b676f63bcd0f3c0fe uncommitted
--- a/sys/man/2/assert
+++ b/sys/man/2/assert
@@ -7,7 +7,7 @@
  .B #include <libc.h>
  .PP
  .B
-#define assert(cond) if(cond);else _assert("cond")
+#define assert(...) if(__VA_ARGS__){}else _assert("__VA_ARGS__")
  .PP
  .B
  void _assert(char* cond)

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2023-11-29  9:15 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-22 23:11 [9front] [PATCH] Fix assert macro to not break on commas Blue-Maned_Hawk
2023-11-23  4:20 ` Jacob Moody
2023-11-25  0:27   ` Blue-Maned_Hawk
2023-11-25  1:09     ` Jacob Moody
2023-11-25  4:34     ` ori
2023-11-25 12:09       ` Blue-Maned_Hawk
2023-11-25 18:46         ` Kurt H Maier
2023-11-25 20:06           ` Steve Simon
2023-11-25 20:39             ` Dan Cross
2023-11-25 22:47               ` Steve Simon
2023-11-26  2:22               ` Kurt H Maier
2023-11-26 17:31                 ` Blue-Maned_Hawk
2023-11-26 18:13                   ` ori
2023-11-26 22:39                     ` Blue-Maned_Hawk
2023-11-26 22:52                       ` ori
2023-11-26 23:30                         ` Blue-Maned_Hawk
2023-11-27  0:00                           ` ori
2023-11-27 11:20                             ` Blue-Maned_Hawk
2023-11-27 15:38                               ` ori
2023-11-27 15:59                                 ` Dan Cross
2023-11-27 22:21                                 ` Blue-Maned_Hawk
2023-11-27 23:59                                   ` ori
2023-11-28  0:30                                     ` Blue-Maned_Hawk
2023-11-28  0:34                                       ` ori
2023-11-29  9:14                                         ` Blue-Maned_Hawk
2023-11-26 19:58                   ` Kurt H Maier
2023-11-26 22:37                     ` Blue-Maned_Hawk
2023-11-25  4:49     ` ori
2023-11-26 18:59     ` Amavect
     [not found]       ` <7025e6e9-fca5-4648-aaea-a80260c35739@sirjofri.de>
2023-11-26 21:11         ` sirjofri
2023-11-26 22:41       ` Blue-Maned_Hawk
2023-11-27 15:44         ` Amavect
2023-11-26 22:36 ` ori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).