fluffos/testsuite/include/socket.h
Yucong Sun ebc86aab02 Every efun has a test: ~130 new files close the whole spec inventory
Systematic review of all 326 spec-declared efuns against
testsuite/single/tests/efuns/; every efun now has a test file named
after it. Pure functions get exact behavioral pins (trig/log/vector
math with domain-error cases, trim family, pcre group semantics,
min/max index form, compress/encoding round trips, bit strings,
Levenshtein string_difference, class assembly/introspection, deep
copy() independence, dump_trace shape, save-string round trips);
environment-dependent efuns get honest contracts (sockets: real
create/bind/listen/connect lifecycle on ephemeral ports; interactive/
protocol/ed efuns: graceful no-interactive behavior; package-gated
efuns guarded by __PACKAGE_*__ / efun_defined()). testsuite/include
gains the driver-shipped socket.h/socket_err.h. Fixtures:
catch_tell_probe (catch_tell recorder + self-mover + make_living),
event_probe, shadow_probe, syntax_parent.

The new coverage flushed out SEVEN real driver bugs, all fixed:
- memory_summary: four division-by-zero sites in memory_share() when a
  value's refcount is 0 (UBSan)
- send_zmp/start_request_term_type: command_giver dereferenced before
  the null check -- crash with no interactive (UBSan)
- socket_create: LPC int loaded into enum socket_mode before
  validation -- UB for out-of-range modes; validated as int first
- async_db_exec: manual callback ref taken before handle validation --
  error() unwind leaked the function pointer (AGENTS.md section 4)
- link(): epilogue abandoned both string arguments -- two shared-string
  refs leaked per call
- assemble_class(): built through copy_array then retagged T_CLASS,
  skewing num_arrays/num_classes and the DEBUGMALLOC tag; now built
  with allocate_class_by_size
- parser_mark_verbs(): marked only the HEAD of each verb's rule list
  (later rules unaccounted), double-marked base verbs through synonym
  entries (verb_syn_t::real overlays the node slot), and computed
  header offsets off NULL for rule-less verbs (UBSan)
- pending resolve() queries had no DEBUGMALLOC accounting at all: new
  pending-query registry + mark_dns_requests(), mirroring
  mark_call_outs

Runner: uncaught errors are now PRINTED as well as recorded (a failing
file was otherwise silent about why).

Verified: testsuite x3 randomized (ASan Debug) + ctest 297, clang
RelWithDebInfo sanitizer full suite, RelWithDebInfo full ctest.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 20:48:48 -04:00

23 lines
420 B
C

/*
* socket.h -- socket mode and option constants for LPC
*/
#ifndef _SOCKET_H_
#define _SOCKET_H_
/* Socket modes */
#define MUD 0
#define STREAM 1
#define DATAGRAM 2
#define STREAM_BINARY 3
#define DATAGRAM_BINARY 4
#define STREAM_TLS 5
#define STREAM_TLS_BINARY 6
/* Socket options */
#define SO_TLS_VERIFY_PEER 1
#define SO_TLS_SNI_HOSTNAME 2
#define SO_TLS_CERT 3
#define SO_TLS_KEY 4
#endif /* _SOCKET_H_ */