Get LIBC_MEM and LIBC_STDIO building with aarch64

This commit is contained in:
Justine Tunney 2023-05-09 08:08:56 -07:00
parent ae0ee59614
commit d04430f4ef
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
81 changed files with 440 additions and 1064 deletions

View file

@ -16,13 +16,13 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "tool/build/lib/interner.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/mem/mem.h"
#include "libc/nexgen32e/crc32.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "libc/x/x.h"
#include "tool/build/lib/interner.h"
#define kInitialItems 16
@ -50,7 +50,7 @@ static void rehash(struct InternerObject *it) {
} while (it->p[j].hash);
memcpy(&it->p[j], &p[i], sizeof(p[i]));
}
free_s(&p);
free(p);
}
/**

View file

@ -114,7 +114,7 @@ void GetOpts(int argc, char *argv[]) {
test_ = true;
break;
case 'o':
fclose_s(&fout_);
fclose(fout_);
if (!(fout_ = fopen((hint_ = optarg), "w"))) {
PrintIoErrorMessage();
exit(1);
@ -191,9 +191,11 @@ int Run(char **paths, size_t count) {
hint_ = "/dev/stdin";
if (!fout_) fout_ = stdout;
rc = RunLengthCode();
rc |= fclose_s(&fin_);
rc |= fclose(fin_);
fin_ = 0;
} else {
rc = fclose_s(&fin_);
rc = fclose(fin_);
fin_ = 0;
for (i = 0; i < count && rc != -1; ++i) {
rc = -1;
if ((fin_ = fopen((hint_ = paths[i]), "r"))) {
@ -219,18 +221,21 @@ int Run(char **paths, size_t count) {
if (rc != -1 && !decompress_) {
rc = RunLengthEncode2();
}
if ((rc |= fclose_s(&fout_)) != -1) {
if ((rc |= fclose(fout_)) != -1) {
unlink(paths[i]);
}
fout_ = 0;
}
}
rc |= fclose_s(&fin_);
rc |= fclose(fin_);
fin_ = 0;
}
}
}
if (rc != -1 && fout_) {
rc = RunLengthEncode2();
rc |= fclose_s(&fout_);
rc |= fclose(fout_);
fout_ = 0;
}
return rc;
}

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "tool/decode/lib/bitabuilder.h"
#include "libc/assert.h"
#include "libc/intrin/bits.h"
#include "libc/log/check.h"
@ -24,7 +25,6 @@
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "tool/decode/lib/bitabuilder.h"
/**
* @fileoverview Sparse bit array builder.
@ -41,8 +41,9 @@ struct BitaBuilder *bitabuilder_new(void) {
void bitabuilder_free(struct BitaBuilder **bbpp) {
if (*bbpp) {
free_s(&(*bbpp)->p);
free_s(bbpp);
free((*bbpp)->p);
free(*bbpp);
*bbpp = 0;
}
}

View file

@ -95,9 +95,11 @@ int main(int argc, char *argv[]) {
for (i = optind; i < argc; ++i) {
CHECK_NOTNULL((in_ = fopen((inpath_ = argv[i]), "r")));
ProcessFile();
CHECK_NE(-1, fclose_s(&in_));
CHECK_NE(-1, fclose(in_));
in_ = 0;
}
CHECK_NE(-1, fclose_s(&out_));
CHECK_NE(-1, fclose(out_));
out_ = 0;
free(line_);
return 0;
}

View file

@ -107,8 +107,10 @@ int main(int argc, char *argv[]) {
for (i = optind; i < argc; ++i) {
CHECK_NOTNULL((fi_ = fopen((inpath_ = argv[i]), "r")));
processfile();
CHECK_NE(-1, fclose_s(&fi_));
CHECK_NE(-1, fclose(fi_));
fi_ = 0;
}
CHECK_NE(-1, fclose_s(&fo_));
CHECK_NE(-1, fclose(fo_));
fo_ = 0;
return 0;
}

View file

@ -16,15 +16,16 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "tool/viz/lib/formatstringtable.h"
#include "libc/intrin/safemacros.internal.h"
#include "libc/str/strwidth.h"
#include "tool/viz/lib/formatstringtable.h"
void *FreeStringTableCells(long yn, long xn, char *T[yn][xn]) {
long y, x;
for (y = 0; y < yn; ++y) {
for (x = 0; x < xn; ++x) {
free_s(&T[y][x]);
free(T[y][x]);
T[y][x] = 0;
}
}
return T;

View file

@ -102,8 +102,10 @@ int main(int argc, char *argv[]) {
for (i = optind; i < argc; ++i) {
CHECK_NOTNULL((in_ = fopen((inpath_ = argv[i]), "r")));
ProcessFile();
CHECK_NE(-1, fclose_s(&in_));
CHECK_NE(-1, fclose(in_));
in_ = 0;
}
CHECK_NE(-1, fclose_s(&out_));
CHECK_NE(-1, fclose(out_));
out_ = 0;
return 0;
}

View file

@ -122,11 +122,13 @@ int main(int argc, char *argv[]) {
while ((getline(&line_, &linecap_, stdin)) != -1) {
processarg(_chomp(line_));
}
free_s(&line_);
free(line_);
line_ = 0;
}
if (cleanup_) {
fprintf(fout_, "%s[0m\n", rawmode_ ? "\e" : "\\e");
}
CHECK_NE(-1, fclose_s(&fout_));
CHECK_NE(-1, fclose(fout_));
fout_ = 0;
return 0;
}

View file

@ -164,10 +164,12 @@ int main(int argc, char *argv[]) {
for (i = optind; i < argc; ++i) {
CHECK_NOTNULL((fi_ = fopen((inpath_ = argv[i]), "r")));
processfile();
CHECK_NE(-1, fclose_s(&fi_));
CHECK_NE(-1, fclose(fi_));
fi_ = 0;
}
flush();
CHECK_NE(-1, fclose_s(&fo_));
CHECK_NE(-1, fclose(fo_));
fo_ = 0;
free(lines_.p);
free(pool_.p);
free(line_);

View file

@ -176,9 +176,11 @@ int main(int argc, char *argv[]) {
for (i = optind; i < argc; ++i) {
CHECK_NOTNULL((in_ = fopen((inpath_ = argv[i]), "r")));
ProcessFile();
CHECK_NE(-1, fclose_s(&in_));
CHECK_NE(-1, fclose(in_));
in_ = 0;
}
CHECK_NE(-1, fclose_s(&out_));
CHECK_NE(-1, fclose(out_));
out_ = 0;
free(line_);
return 0;
}