From 0b1e310749e83d06012aa25b8df3facb1d0e3153 Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Fri, 4 Sep 2026 11:24:43 +0800 Subject: [PATCH] remove extralib --- src/autoscaler/scaler/include/scaler.h | 2 +- src/flake.lock | 98 ++++---------------------- src/flake.nix | 5 +- src/include/xcelist.h | 44 ++++++++++++ src/lib/meson.build | 1 + src/lib/xcelist.c | 82 +++++++++++++++++++++ src/nixSupport/xce.nix | 3 - 7 files changed, 144 insertions(+), 91 deletions(-) create mode 100644 src/include/xcelist.h create mode 100644 src/lib/xcelist.c diff --git a/src/autoscaler/scaler/include/scaler.h b/src/autoscaler/scaler/include/scaler.h index 96079fa0..c0870105 100644 --- a/src/autoscaler/scaler/include/scaler.h +++ b/src/autoscaler/scaler/include/scaler.h @@ -12,7 +12,7 @@ #include "xce/types.h" #include "xlist.h" #include "zarray.h" -#include +#include "xcelist.h" // in seconds #define DEFAULT_CHECK_INTERVAL 30 diff --git a/src/flake.lock b/src/flake.lock index 65e369a6..918ad782 100644 --- a/src/flake.lock +++ b/src/flake.lock @@ -1,25 +1,5 @@ { "nodes": { - "extralib": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1764921004, - "narHash": "sha256-Odh7nfv8ynvrM0b7BxsDgnM76dTJfjakn+U5Re6LCBc=", - "ref": "main", - "rev": "d370b0450779b6c8befc88fd41cc06c9e1e4e40a", - "revCount": 3, - "type": "git", - "url": "ssh://forgejo@gitea.shenrs.eu/nexa/extralibs" - }, - "original": { - "ref": "main", - "type": "git", - "url": "ssh://forgejo@gitea.shenrs.eu/nexa/extralibs" - } - }, "flake-compat": { "flake": false, "locked": { @@ -126,28 +106,10 @@ "type": "github" } }, - "flake-utils_6": { - "inputs": { - "systems": "systems_6" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "librtti": { "inputs": { - "flake-utils": "flake-utils_3", - "nixpkgs": "nixpkgs_2", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs", "xbuild": "xbuild" }, "locked": { @@ -168,8 +130,8 @@ "nix-appimage": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils_5", - "nixpkgs": "nixpkgs_4" + "flake-utils": "flake-utils_4", + "nixpkgs": "nixpkgs_3" }, "locked": { "lastModified": 1757920913, @@ -186,22 +148,6 @@ } }, "nixpkgs": { - "locked": { - "lastModified": 1764517877, - "narHash": "sha256-pp3uT4hHijIC8JUK5MEqeAWmParJrgBVzHLNfJDZxg4=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "2d293cbfa5a793b4c50d17c05ef9e385b90edf6c", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { "locked": { "lastModified": 1764950072, "narHash": "sha256-BmPWzogsG2GsXZtlT+MTcAWeDK5hkbGRZTeZNW42fwA=", @@ -217,7 +163,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_2": { "locked": { "lastModified": 1764667669, "narHash": "sha256-7WUCZfmqLAssbDqwg9cUDAXrSoXN79eEEq17qhTNM/Y=", @@ -233,7 +179,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_3": { "locked": { "lastModified": 1745997950, "narHash": "sha256-FklMkU+bPPx0L3i6pdrw65js05VO9He3DTeKguX9GQY=", @@ -249,7 +195,7 @@ "type": "github" } }, - "nixpkgs_5": { + "nixpkgs_4": { "locked": { "lastModified": 1769461804, "narHash": "sha256-msG8SU5WsBUfVVa/9RPLaymvi5bI8edTavbIq3vRlhI=", @@ -265,7 +211,7 @@ "type": "github" } }, - "nixpkgs_6": { + "nixpkgs_5": { "locked": { "lastModified": 1777954456, "narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=", @@ -392,11 +338,10 @@ }, "root": { "inputs": { - "extralib": "extralib", - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "librtti": "librtti", "nix-appimage": "nix-appimage", - "nixpkgs": "nixpkgs_5", + "nixpkgs": "nixpkgs_4", "xbuild": "xbuild_2" } }, @@ -475,21 +420,6 @@ "type": "github" } }, - "systems_6": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "uv2nix": { "inputs": { "nixpkgs": [ @@ -541,8 +471,8 @@ }, "xbuild": { "inputs": { - "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_3" + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_2" }, "locked": { "lastModified": 1769064169, @@ -561,8 +491,8 @@ }, "xbuild_2": { "inputs": { - "flake-utils": "flake-utils_6", - "nixpkgs": "nixpkgs_6", + "flake-utils": "flake-utils_5", + "nixpkgs": "nixpkgs_5", "npm-lockfile-fix": "npm-lockfile-fix", "pyproject-build-systems": "pyproject-build-systems", "pyproject-nix": "pyproject-nix_2", diff --git a/src/flake.nix b/src/flake.nix index 663c82ec..a1b5eb7c 100644 --- a/src/flake.nix +++ b/src/flake.nix @@ -4,13 +4,12 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; xbuild.url = "github:shen390s/my-nix-channel?ref=master"; - extralib.url = "git+ssh://forgejo@gitea.shenrs.eu/nexa/extralibs?ref=main"; librtti.url = "git+ssh://forgejo@gitea.shenrs.eu/rshen/librtti?ref=master"; flake-utils.url = "github:numtide/flake-utils"; nix-appimage.url = "github:ralismark/nix-appimage"; }; - outputs = { self, nixpkgs, xbuild, extralib, librtti, flake-utils, nix-appimage }: + outputs = { self, nixpkgs, xbuild, librtti, flake-utils, nix-appimage }: let supportedSystems = [ "x86_64-linux" ]; myCommitId = @@ -60,7 +59,7 @@ in flake-utils.lib.eachSystem supportedSystems ( system: let - mypkgs = xbuild.packages.${system} // extralib.packages.${system} // librtti.packages.${system}; + mypkgs = xbuild.packages.${system} // librtti.packages.${system}; overlays = [ (final: prev: mypkgs // prev) ]; diff --git a/src/include/xcelist.h b/src/include/xcelist.h new file mode 100644 index 00000000..ddaabc2a --- /dev/null +++ b/src/include/xcelist.h @@ -0,0 +1,44 @@ +#if !defined(__XCELIST_H__) +#define __XCELIST_H__ 1 + +/* + * Intrusive doubly-linked list. + * + * A list entry must have its `forw` and `back` pointers as its first two + * members so that a user-defined node (e.g. `struct { void* forw; void* back; + * ...payload... }`) can be safely cast to `xcelist_entry_t*`. + * + * The list head (`xcelist_t`) is itself layout-compatible with an entry: its + * `forw` field points to the first entry (or back to itself when empty) and + * its `back` field points to the last entry. `numEnts` tracks the entry count. + * + * This replaces the previously external `basiclib/list.h` (extralib) with the + * minimal subset of functionality actually used in-tree. + */ + +typedef struct _xcelist_entry { + struct _xcelist_entry* forw; + struct _xcelist_entry* back; +} xcelist_entry_t; + +typedef struct _xcelist { + /* head sentinel: must mirror xcelist_entry_t layout (forw/back first) */ + xcelist_entry_t* forw; + xcelist_entry_t* back; + int numEnts; + char* name; +} xcelist_t; + +/* Create an empty list. `name` is copied and may be NULL. Returns NULL on OOM. */ +extern xcelist_t* list_create(const char* name); + +/* Destroy a list. Does not free the entries; caller owns them. */ +extern void list_destroy(xcelist_t* list); + +/* Append `entry` to the back (tail) of `list`. */ +extern void list_insert_entry_back(xcelist_t* list, xcelist_entry_t* entry); + +/* Unlink `entry` from `list`. Does not free `entry`. */ +extern void list_entry_remove(xcelist_t* list, xcelist_entry_t* entry); + +#endif diff --git a/src/lib/meson.build b/src/lib/meson.build index 65f5072c..01b29d0e 100644 --- a/src/lib/meson.build +++ b/src/lib/meson.build @@ -82,6 +82,7 @@ libxce_src = [ gen_srcs[0], 'window.c', 'xceapi.c', 'xcectx.c', + 'xcelist.c', 'xlist.c', 'xstring.c', 'zarray.c', diff --git a/src/lib/xcelist.c b/src/lib/xcelist.c new file mode 100644 index 00000000..06f1c0b6 --- /dev/null +++ b/src/lib/xcelist.c @@ -0,0 +1,82 @@ +#include +#include + +#include "xcelist.h" + +/* + * Intrusive circular doubly-linked list. + * + * The list head (`xcelist_t`) doubles as a sentinel: when the list is empty, + * both `forw` and `back` point back at the head. This keeps insertion and + * removal branch-free while allowing `list->forw` to be read directly as the + * first entry (as done by the autoscaler demand queue). + */ + +xcelist_t* list_create(const char* name) +{ + xcelist_t* list = (xcelist_t*)calloc(1, sizeof(xcelist_t)); + if (!list) { + return NULL; + } + + /* empty list: head points at itself */ + list->forw = (xcelist_entry_t*)list; + list->back = (xcelist_entry_t*)list; + list->numEnts = 0; + + if (name) { + list->name = strdup(name); + if (!list->name) { + free(list); + return NULL; + } + } + + return list; +} + +void list_destroy(xcelist_t* list) +{ + if (!list) { + return; + } + free(list->name); + free(list); +} + +void list_insert_entry_back(xcelist_t* list, xcelist_entry_t* entry) +{ + xcelist_entry_t* head; + xcelist_entry_t* last; + + if (!list || !entry) { + return; + } + + head = (xcelist_entry_t*)list; + last = head->back; + + entry->forw = head; + entry->back = last; + last->forw = entry; + head->back = entry; + + list->numEnts++; +} + +void list_entry_remove(xcelist_t* list, xcelist_entry_t* entry) +{ + if (!list || !entry || entry == (xcelist_entry_t*)list) { + return; + } + + entry->back->forw = entry->forw; + entry->forw->back = entry->back; + + entry->forw = NULL; + entry->back = NULL; + + if (list->numEnts > 0) { + list->numEnts--; + } +} diff --git a/src/nixSupport/xce.nix b/src/nixSupport/xce.nix index 989cbb32..d52eb49b 100644 --- a/src/nixSupport/xce.nix +++ b/src/nixSupport/xce.nix @@ -77,9 +77,6 @@ stdenv.mkDerivation { libcyaml libyaml libcgroup - (extralib.overrideAttrs (oldAttrs: { - separateDebugInfo = true; - })) packcc # Python — for xceadmin (admin config tool, src/xceadmin/). pycapnp links # against the capnproto C++ runtime above; nix's python3Packages.pycapnp