[libc-commits] [libc] [libc] Implement alphasort in dirent (PR #226487)

Alexey Samsonov via libc-commits libc-commits at lists.llvm.org
Mon Sep 28 15:03:26 PDT 2026


================
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Unit tests for the POSIX alphasort function.
+///
+//===----------------------------------------------------------------------===//
+
+#include "src/dirent/alphasort.h"
+
+#include "hdr/types/struct_dirent.h"
+#include "src/stdlib/qsort.h"
+#include "test/UnitTest/Test.h"
+
+namespace {
+
+template <size_t N = 64> struct MockDirent {
----------------
vonosmas wrote:

Why are you using a template here, even though the extra size is constant?

Also, it looks like you can just reinterpret the buffer and initialize the dirent with proper string in a regular constructor.

https://github.com/llvm/llvm-project/pull/226487


More information about the libc-commits mailing list