43 Commits

Author SHA1 Message Date
262b0e5e52 Attempt to track CPU usage of libuv worker threads.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4198 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-03-01 01:36:26 +00:00
1e3807bcb9 Exposed functions to encrypt and decrypt private messages.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4197 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-26 19:51:54 +00:00
2ed3295f77 sqlite-amalgamation-3410000.zip
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4196 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-26 03:12:14 +00:00
8c9d687d50 Variety of minor fixes I've been running with. SSB web interface changes. calloc overallocation fix. Use sqlAsync. Probably some other things.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4195 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-23 01:29:54 +00:00
b8b694864e Whoops, overallocated.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4194 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-20 02:42:11 +00:00
961109635b Latest libsodium-1.0.18-stable.tar.gz.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4193 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-19 23:23:53 +00:00
86bc46a11e Track memory allocations with a linked list. This is only about 3x slower than without tracking instead of 5x and growing.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4192 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-19 22:28:36 +00:00
a6a6fe75ec Aha, one more leak in sqlAsync.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4191 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-19 13:51:06 +00:00
f55f863867 Some unused global variables.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4190 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-19 13:16:55 +00:00
4ce988d00b Memory leak in maskBytes.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4189 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-19 02:01:59 +00:00
1548a8a852 One less alloc for setTimeout.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4188 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-19 01:28:14 +00:00
a9551b057b Trace more things. Add a CORS header for /mem so I can make an app to examine it. Fix a memory leak. Fix tf_realloc(NULL, 0).
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4187 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-18 23:43:00 +00:00
88c7d91858 Brute force memory tracking.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4186 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-18 21:00:39 +00:00
53cb80ebf7 Replace the sqlite allocator, and use our own tracking for stats. Want to use this to collect callstacks for all allocations.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4185 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-18 19:14:06 +00:00
1f67343d75 Make traces work with multiple threads, I think.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4184 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-18 00:51:22 +00:00
4bea8bb6ba sqlite thread safety and extended result codes, mainly.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4183 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-17 22:43:19 +00:00
8e1461b3f1 Catch more sqlite errors.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4182 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-17 02:04:48 +00:00
90b513d070 Fix syntax errors not propagating.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4181 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-17 01:42:56 +00:00
8a2d3d4669 Pass around SQL errors slightly better.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4180 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-16 00:06:45 +00:00
1741403206 More memory leaks.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4179 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-15 02:59:46 +00:00
980db880cc Memory leak.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4178 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-15 02:56:01 +00:00
507a62539d Fix exporting.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4177 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-15 02:43:08 +00:00
6b5d73ed5c Vague attempt at some more cleanup, and stick pthread_self() in the traces.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4176 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-15 02:34:46 +00:00
1f77df7a90 Remove dependency on base64c. Use libsodium's. Also consolidate the calls, as the usage is quite special.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4175 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-14 03:15:24 +00:00
fa87462405 Finish writing this code. Yep.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4174 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-14 02:13:08 +00:00
a5f9f927e6 Fix some memory leaks I just introduced.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4173 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-08 01:50:47 +00:00
b35d74ce36 Allow running read-only sqlite queries from libuv worker threads. Needs so much more testing.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4172 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-08 01:29:44 +00:00
ac60be14a5 Sure, we can identify SVG files.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4171 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-07 23:39:04 +00:00
beda047eb0 Disable Nagle's algorithm before we start the TLS handshake. Just speculation that it will help with some responsiveness.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4170 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-06 02:29:00 +00:00
f6742bebf3 Tracing will continue until performance improves.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4169 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-03 15:06:18 +00:00
7f334ad783 Fine, only malloc_trim if it looks like we have it.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4168 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-03 14:20:26 +00:00
ffda896308 Finish import.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4167 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-03 14:09:53 +00:00
b2fbe9dfac Stale doc file. Fix hashtag links. Trace some GC stuff and try malloc_trim, whynot.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4166 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-03 14:01:05 +00:00
6d6c41bffa Oops. Cleanup.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4165 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-02 02:48:07 +00:00
e04d137af5 Refactored import and export. No user on disk.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4164 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-02 02:09:05 +00:00
ec52e62908 Move apps/cory/ => apps/. Going to change import and export to support this.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4163 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-02 00:18:22 +00:00
6104af0d70 Smaller docker image. Why not.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4162 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-01 23:47:07 +00:00
0ca05e297d No more global settings file.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4161 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-01 23:40:21 +00:00
e0dcec074c Add process name to trace.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4160 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-01 23:20:16 +00:00
a8cecb5c64 Fix trace producing invalid JSON.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4159 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-02-01 03:15:22 +00:00
582ee0e4d7 var => let
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4158 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-01-31 02:48:56 +00:00
0ba54c2b7b Update lit element. Better drafts. Compose content warnings.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4157 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-01-30 01:45:23 +00:00
3c288f7f68 Remove duplicate apps entries on import.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4156 ed5197a5-7fde-0310-b194-c3ffbd925b24
2023-01-29 01:58:57 +00:00
154 changed files with 8850 additions and 4556 deletions

View File

@ -2,8 +2,10 @@ FROM bitnami/minideb:bullseye AS build
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libssl-dev
gcc \
libc6-dev \
libssl-dev \
make
COPY . /app
RUN make -C /app -j $(nproc) release

View File

@ -76,11 +76,6 @@ $(APP_OBJS): CFLAGS += \
-Ideps/xopt \
-Werror
BASE64C_SOURCES := deps/base64c/src/base64c.c
BASE64C_OBJS := $(call get_objs,BASE64C_SOURCES)
$(BASE64C_OBJS): CFLAGS += \
-Wno-sign-compare
BLOWFISH_SOURCES := \
deps/crypt_blowfish/crypt_blowfish.c \
deps/crypt_blowfish/crypt_gensalt.c \
@ -207,6 +202,7 @@ SODIUM_SOURCES := \
deps/libsodium/src/libsodium/randombytes/randombytes.c \
deps/libsodium/src/libsodium/randombytes/sysrandom/randombytes_sysrandom.c \
deps/libsodium/src/libsodium/sodium/core.c \
deps/libsodium/src/libsodium/sodium/codecs.c \
deps/libsodium/src/libsodium/sodium/runtime.c \
deps/libsodium/src/libsodium/sodium/utils.c
SODIUM_OBJS := $(call get_objs,SODIUM_SOURCES)
@ -225,6 +221,7 @@ $(SQLITE_OBJS): CFLAGS += \
-DSQLITE_DBCONFIG_DEFAULT_DEFENSIVE \
-DSQLITE_ENABLE_FTS5 \
-DSQLITE_ENABLE_JSON1 \
-DSQLITE_THREADSAFE=1 \
-DSQLITE_MAX_LENGTH=5242880 \
-DSQLITE_MAX_SQL_LENGTH=100000 \
-DSQLITE_MAX_COLUMN=100 \
@ -330,7 +327,6 @@ all: $(BUILD_TYPES)
ALL_APP_OBJS := \
$(APP_OBJS) \
$(BASE64C_OBJS) \
$(BLOWFISH_OBJS) \
$(LIBBACKTRACE_OBJS) \
$(PICOHTTPPARSER_OBJS) \

3
apps/admin.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "tildefriends-app"
}

3
apps/api.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "tildefriends-app"
}

3
apps/apps.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "tildefriends-app"
}

View File

@ -1 +0,0 @@
{"type":"tildefriends-app","files":{"app.js":"&uhGJsy5+qBgOgEgMqCTDasK+C+GWGptHKfPiAsD5eGA=.sha256","index.html":"&D3JwdPXy/QsLXkmwNDrBFXdzxfqO1/JGxfqEArnS5v4=.sha256","lit.min.js":"&3FfrVflmGr0n4lvN0GriN1Qz1lEw31SbZxRSJrcXR28=.sha256","script.js":"&TZ2ymD6cFVUjQleGcDslt8apjp7k3xLlfv2F8rQVM4I=.sha256"}}

View File

@ -1 +0,0 @@
{"type":"tildefriends-app","files":{"app.js":"&p35JmopfHf8hFh3Y9x6LrIxiUwaJZ5Nabzi2sVXpKoo=.sha256"}}

View File

@ -1 +0,0 @@
{"type":"tildefriends-app","files":{"app.js":"&qEJDfZ43KazIxiZl8OCKb2uaDOsPkxnIohEzQ1LLFpg=.sha256"}}

View File

@ -1 +0,0 @@
{"type":"tildefriends-app","files":{"app.js":"&V5o5IM9/OUyIsVkjkMW/X0i/tflQOSVJuJBmHdMT9aM=.sha256"}}

View File

@ -1 +0,0 @@
{"type":"tildefriends-app","files":{"app.js":"&WEvJYebSMi5d2eXgUwJJmvR/Q4slFg3zHYB8Q2mXJII=.sha256","index.md":"&79+ntX4sRvg+MboV5nMFz01BSicxsWIQRx719VHS8uk=.sha256","todo.md":"&hQABwP24zFFhdHagRMF3Am7rV2yH19e+0xJ4wnZ4kfM=.sha256","structure.md":"&jph8x/fMXKOd4I0ZiUVb0ZLTfPQ7gBWoxJPrvtX6vtw=.sha256","guide.md":"&SgnGL0+rjetY2o9A2+lVRbNvHIkqKwMnZr9gXWneIlc=.sha256","ssb.md":"&JH1JfoTaCcUifCpnAwhImKBACI0PHoLhoOw1WAnWpLw=.sha256","vision.md":"&v2wu2MGlhNvaALQQ9rGna7ZeEQWSghFgQcDfD5xEyE0=.sha256"}}

View File

@ -1,17 +0,0 @@
# ID Refactor
[Back to index](#index)
## Goals
- no way to get private key in javascript
- ssb.c syncs/broadcasts/... efficiently for everybody
## Schema
- separate table to discourage leakage
- `CREATE TABLE identities (user TEXT, public TEXT, secret TEXT);`
## API
- `ssb.createIdentity()` -> `id`
- `ssb.getIdentities()` => `[id, ...]`
- `ssb.deleteIdentity(id)`
- `ssb.post(id, ...)`
- `ssb.appendMessage(id, ...)`

View File

@ -1 +0,0 @@
{"type":"tildefriends-app","files":{"app.js":"&3d9ABFgRwQvWsYbFv/rzimtnLDnVrWlGtdw7serFIGw=.sha256"}}

View File

@ -1 +0,0 @@
{"type":"tildefriends-app","files":{"app.js":"&1HWTkyCc1doft6dyKF5FDxtRAErNeY25CBrfZbKPpyo=.sha256","lit-all.min.js":"&XKgdRySJuiZeZvchNFGjVWn0XOVhQFmG7/HTWYQ8s68=.sha256","index.html":"&TxhFekB9ov7tf/fmkAg7x5797i27oLidhgxEfDKC0T0=.sha256","script.js":"&G8puK9Q4MngHy3D4ppcKyT49WKbHD2OCeUcAw2ghTDE=.sha256","lit-all.min.js.map":"&lA9iFp1YbqSndxXZuwtgmrj7NDMkN71nJITbtjWL3VA=.sha256","tf-id-picker.js":"&maN8DUFrmRxW5nsVyOAMk5k1ekcz/pfzvSS99ac3jo8=.sha256","tf-app.js":"&F0fyawIO410YFidrzFjlHeY++sZy6ledf6CAXB+45U4=.sha256","tf-message.js":"&HToh+7UCoanBzlr/TEsy/JG4OS2IBU1tMuzjuNmUkAo=.sha256","tf-user.js":"&bXTedgBudTQLXEBPY9R8OLfQ/ZLpo8YRU9Oq/wuGG3Y=.sha256","tf-utils.js":"&lYNeL7cVlDgcqrfkoRIe69DHZeqSZMiHhZIieblHbU0=.sha256","commonmark.min.js":"&bfBaMLU19d1p/vPBF9hlARqDX002KXG/UOfxOahZhe4=.sha256","tf-compose.js":"&7HZLHf5NB5hE6FW0hiXNvM17ekGBn5BBle1bvnjVjyo=.sha256","emojis.json":"&h3P4pez+AI4aYdsN0dJ3pbUEFR0276t9AM20caj/W/s=.sha256","emojis.js":"&tOkUocccQWBzkNzSEf9VMltkTSHcUALYSPYVWmJMoBc=.sha256","tf-styles.js":"&LFeL/vWgrv4N8q/mBrQAnhbaOI+dXNJYvH9bn1bXSqQ=.sha256","tf-profile.js":"&vRKjsnYvOiHCQahzEfznCvP5YDwUPtltlpWf+pxwZ1Y=.sha256","commonmark-linkify.js":"&X+hNNkmSRvKY86khyAun+cXksquXbMakZdINbGbx30g=.sha256","tf-tab-search.js":"&ESt2vMG19sH5j6ungKua/ZuvIGslyuWyb3juXdOCecg=.sha256","tf-tab-news.js":"&fY+thANurOKU2/RhDt411ZtkxW0nV24+hLEf00Z1sTY=.sha256","tf-tab-connections.js":"&ywqBz3w63R6naH09kZ+01A0SfmtuSfk8QPBXWsli0yg=.sha256","tf-news.js":"&Zn+vxLUqVJbo/q6RcW8ezvbdilzllvXhZRyXk8kYwL0=.sha256","tribute.css":"&9FogMzZHKXCfGb7mlh7z+/wiNZzBsOB/tKoh6MfYJno=.sha256","tribute.esm.js":"&P1wKqCfYULpR/ahSB98JP8xaxfikuZwwtT6I/SAo7/Y=.sha256","commonmark-hashtag.js":"&fudY0YdvcMjVCSZ0oiCqUt0+bVT0a06j5TcjWaCDO8E=.sha256"}}

File diff suppressed because one or more lines are too long

View File

@ -1,57 +0,0 @@
import {LitElement, html} from './lit-all.min.js';
import * as tfrpc from '/static/tfrpc.js';
class TfConnectionsElement extends LitElement {
static get properties() {
return {
broadcasts: {type: Array},
identities: {type: Array},
connections: {type: Array},
users: {type: Object},
}
}
constructor() {
super();
let self = this;
this.broadcasts = [];
this.identities = [];
this.connections = [];
this.users = {};
tfrpc.rpc.getAllIdentities().then(function(identities) {
self.identities = identities || [];
});
}
_emit_change() {
let changed_event = new Event('change', {
srcElement: this,
});
this.dispatchEvent(changed_event);
}
changed(event) {
this.selected = event.srcElement.value;
tfrpc.rpc.localStorageSet('whoami', this.selected);
this._emit_change();
}
render() {
return html`
<h2>Broadcasts</h2>
<ul>
${this.broadcasts.map(x => html`<li><tf-user id=${x.pubkey} .users=${this.users}></tf-user></li>`)}
</ul>
<h2>Connections</h2>
<ul>
${this.connections.map(x => html`<li><tf-user id=${x} .users=${this.users}></tf-user></li>`)}
</ul>
<h2>Local Accounts</h2>
<ul>
${this.identities.map(x => html`<li><tf-user id=${x} .users=${this.users}></tf-user></li>`)}
</ul>
`;
}
}
customElements.define('tf-connections', TfConnectionsElement);

View File

@ -1 +0,0 @@
{"type":"tildefriends-app","files":{"app.js":"&QUR1tKa15B5Or8AfPX/8Zs87teSeX0Mh/HF7PEPBom0=.sha256","index.html":"&QXhwvxhHc9fa8iL6088hGDu9FgWdY7wkXgvU2BMNv0A=.sha256","lit-core.min.js":"&tP9KhbgwF1chFqPtkNZ12Yx9AfkpnSjFiPcX5Pw5J9g=.sha256","script.js":"&KgOaUVjBM4MzSy7PpUVQHETuvgXAx2JGPJABksBg+QY=.sha256"}}

3
apps/db.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "tildefriends-app"
}

3
apps/docs.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "tildefriends-app"
}

3
apps/follow.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "tildefriends-app"
}

View File

@ -15,7 +15,7 @@ async function following(db, id) {
f = {users: [], sequence: 0, version: k_version};
}
f.users = new Set(f.users);
await ssb.sqlStream(
await ssb.sqlAsync(
"SELECT "+
" sequence, "+
" json_extract(content, '$.contact') AS contact, "+
@ -73,7 +73,7 @@ async function getAbout(db, id) {
if (!f || f.version != k_version) {
f = {about: {}, sequence: 0, version: k_version};
}
await ssb.sqlStream(
await ssb.sqlAsync(
"SELECT "+
" sequence, "+
" content "+
@ -109,7 +109,7 @@ async function getAbout(db, id) {
async function getSize(db, id) {
let size = 0;
await ssb.sqlStream(
await ssb.sqlAsync(
"SELECT (SUM(LENGTH(content)) + SUM(LENGTH(author)) + SUM(LENGTH(id))) AS size FROM messages WHERE author = ?1",
[id],
function (row) {

3
apps/ssb.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "tildefriends-app"
}

View File

@ -47,7 +47,7 @@ tfrpc.register(async function closeConnection(id) {
});
tfrpc.register(async function query(sql, args) {
let result = [];
await ssb.sqlStream(sql, args, function callback(row) {
await ssb.sqlAsync(sql, args, function callback(row) {
result.push(row);
});
return result;

View File

@ -39,7 +39,7 @@ function splitMatches(text, regexp) {
return result;
}
const regex = new RegExp("\\W#[\\w-]+");
const regex = new RegExp("(?<!\w)#[\\w-]+");
function split(textNodes) {
const text = textNodes.map(n => n.literal).join("");

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -133,7 +133,11 @@ class TfElement extends LitElement {
`, []))[0].max_row_id;
let result = await this.following_deep_internal(ids, depth, blocking, cache.last_row_id, cache.following, max_row_id);
cache.last_row_id = max_row_id;
await tfrpc.rpc.databaseSet('following', JSON.stringify(cache));
let store = JSON.stringify(cache);
/* 2023-02-20: Exceeding message size. */
if (store.length < 512 * 1024) {
await tfrpc.rpc.databaseSet('following', store);
}
return [result, cache.following];
}

View File

@ -11,7 +11,6 @@ class TfComposeElement extends LitElement {
users: {type: Object},
root: {type: String},
branch: {type: String},
mentions: {type: Object},
apps: {type: Object},
drafts: {type: Object},
}
@ -24,7 +23,6 @@ class TfComposeElement extends LitElement {
this.users = {};
this.root = undefined;
this.branch = undefined;
this.mentions = {};
this.apps = undefined;
this.drafts = {};
}
@ -34,6 +32,8 @@ class TfComposeElement extends LitElement {
return '';
}
/* Update mentions. */
let draft = this.get_draft();
let updated = false;
for (let match of text.matchAll(/\[([^\[]+)]\(([@&%][^\)]+)/g)) {
let name = match[1];
let link = match[2];
@ -50,14 +50,19 @@ class TfComposeElement extends LitElement {
break;
}
}
if (!this.mentions[link]) {
this.mentions[link] = {
if (!draft.mentions) {
draft.mentions = {};
}
if (!draft.mentions[link]) {
draft.mentions[link] = {
link: link,
}
}
this.mentions[link].name = name.startsWith('@') ? name.substring(1) : name;
this.mentions = Object.assign({}, this.mentions);
console.log(this.mentions);
draft.mentions[link].name = name.startsWith('@') ? name.substring(1) : name;
updated = true;
}
if (updated) {
this.requestUpdate();
}
return tfutils.markdown(text);
}
@ -66,6 +71,11 @@ class TfComposeElement extends LitElement {
let edit = this.renderRoot.getElementById('edit');
let preview = this.renderRoot.getElementById('preview');
preview.innerHTML = this.process_text(edit.value);
let content_warning = this.renderRoot.getElementById('content_warning');
let content_warning_preview = this.renderRoot.getElementById('content_warning_preview');
if (content_warning && content_warning_preview) {
content_warning_preview.innerText = content_warning.value;
}
}
notify(draft) {
@ -79,9 +89,11 @@ class TfComposeElement extends LitElement {
}));
}
change(event) {
let edit = this.renderRoot.getElementById('edit');
this.notify(edit.value);
change() {
let draft = this.get_draft();
draft.text = this.renderRoot.getElementById('edit')?.value;
draft.content_warning = this.renderRoot.getElementById('content_warning')?.value;
this.notify(draft);
}
convert_to_format(buffer, type, mime_type) {
@ -111,6 +123,7 @@ class TfComposeElement extends LitElement {
async add_file(file) {
try {
let draft = this.get_draft();
let self = this;
let buffer = await file.arrayBuffer();
let type = file.type;
@ -131,16 +144,19 @@ class TfComposeElement extends LitElement {
}
let id = await tfrpc.rpc.store_blob(buffer);
let name = type.split('/')[0] + ':' + file.name;
self.mentions[id] = {
if (!draft.mentions) {
draft.mentions = {};
}
draft.mentions[id] = {
link: id,
name: name,
type: type,
size: buffer.length ?? buffer.byteLength,
};
self.mentions = Object.assign({}, self.mentions);
let edit = self.renderRoot.getElementById('edit');
edit.value += `\n![${name}](${id})`;
self.change();
self.input();
} catch(e) {
alert(e?.message);
}
@ -162,6 +178,7 @@ class TfComposeElement extends LitElement {
submit() {
let self = this;
let draft = this.get_draft();
let edit = this.renderRoot.getElementById('edit');
let message = {
type: 'post',
@ -171,15 +188,18 @@ class TfComposeElement extends LitElement {
message.root = this.root;
message.branch = this.branch;
}
if (Object.values(this.mentions).length) {
message.mentions = Object.values(this.mentions);
if (Object.values(draft.mentions || {}).length) {
message.mentions = Object.values(draft.mentions);
}
if (draft.content_warning !== undefined) {
message.contentWarning = draft.content_warning;
}
console.log('Would post:', message);
tfrpc.rpc.appendMessage(this.whoami, message).then(function() {
edit.value = '';
self.mentions = {};
self.change();
self.notify(undefined);
self.requestUpdate();
}).catch(function(error) {
alert(error.message);
});
@ -216,9 +236,21 @@ class TfComposeElement extends LitElement {
tribute.attach(this.renderRoot.getElementById('edit'));
}
updated() {
super.updated();
let edit = this.renderRoot.getElementById('edit');
if (this.last_updated_text !== edit.value) {
let preview = this.renderRoot.getElementById('preview');
preview.innerHTML = this.process_text(edit.value);
this.last_updated_text = edit.value;
}
}
remove_mention(id) {
delete this.mentions[id];
this.mentions = Object.assign({}, this.mentions);
let draft = this.get_draft();
delete draft.mentions[id];
this.notify(draft);
this.requestUpdate();
}
render_mention(mention) {
@ -251,7 +283,10 @@ class TfComposeElement extends LitElement {
};
}
}
this.mentions = Object.assign(this.mentions || {}, mentions);
let draft = this.get_draft();
draft.mentions = Object.assign(draft.mentions || {}, mentions);
this.requestUpdate();
this.notify(draft);
this.apps = null;
}
@ -279,14 +314,53 @@ class TfComposeElement extends LitElement {
}
}
set_content_warning(value) {
let draft = this.get_draft();
draft.content_warning = value;
this.notify(draft);
this.requestUpdate();
}
render_content_warning() {
let self = this;
let draft = this.get_draft();
if (draft.content_warning !== undefined) {
return html`
<div>
<input type="checkbox" id="cw" @change=${() => self.set_content_warning(undefined)} checked></input>
<label for="cw">CW</label>
<input type="text" id="content_warning" @input=${this.input} @change=${this.change} value=${draft.content_warning}></input>
</div>
`;
} else {
return html`
<input type="checkbox" id="cw" @change=${() => self.set_content_warning('')}></input>
<label for="cw">CW</label>
`;
}
}
get_draft() {
return this.drafts[this.branch || ''] || {};
}
render() {
let self = this;
let draft = self.get_draft();
let content_warning =
draft.content_warning !== undefined ?
html`<div id="content_warning_preview" class="content_warning">${draft.content_warning}</div>` :
undefined;
let result = html`
<div style="display: flex; flex-direction: row; width: 100%">
<textarea id="edit" @input=${this.input} @change=${this.change} @paste=${this.paste} style="flex: 1 0 50%">${this.drafts[this.branch || '']}</textarea>
<div id="preview" style="flex: 1 0 50%"></div>
<textarea id="edit" @input=${this.input} @change=${this.change} @paste=${this.paste} style="flex: 1 0 50%">${draft.text}</textarea>
<div style="flex: 1 0 50%">
${content_warning}
<div id="preview"></div>
</div>
</div>
${Object.values(this.mentions).map(x => self.render_mention(x))}
${Object.values(draft.mentions || {}).map(x => self.render_mention(x))}
${this.render_content_warning()}
${this.render_attach_app()}
<input type="button" value="Submit" @click=${this.submit}></input>
<input type="button" value="Attach" @click=${this.attach}></input>

View File

@ -300,7 +300,7 @@ class TfMessageElement extends LitElement {
this.render_raw() :
unsafeHTML(tfutils.markdown(content.text));
let content_warning = html`
<div style="border: 1px solid #fff; border-radius: 1em; padding: 8px; margin: 4px" @click=${x => this.toggle_expanded(':cw')}>${content.contentWarning}</div>
<div class="content_warning" @click=${x => this.toggle_expanded(':cw')}>${content.contentWarning}</div>
`;
let content_html =
html`
@ -400,6 +400,11 @@ class TfMessageElement extends LitElement {
`;
} else if (content.type === 'pub') {
return small_frame(html`
<style>
span {
overflow-wrap: anywhere;
}
</style>
<span>
<div>
🍻 <tf-user .users=${this.users} id=${content.address.key}></tf-user>

View File

@ -145,7 +145,7 @@ class TfNewsElement extends LitElement {
return recursive_sort(roots, true);
}
async load_and_render(messages) {
load_and_render(messages) {
let messages_by_id = this.process_messages(messages);
let final_messages = this.finalize_messages(messages_by_id);
return html`
@ -156,8 +156,7 @@ class TfNewsElement extends LitElement {
}
render() {
let messages = this.load_and_render(this.messages || []);
return html`${until(messages, html`<div>Loading placeholders...</div>`)}`;
return this.load_and_render(this.messages || []);
}
}

View File

@ -29,4 +29,11 @@ img {
color: #088;
background-color: #fff;
}
.content_warning {
border: 1px solid #fff;
border-radius: 1em;
padding: 8px;
margin: 4px;
}
`;

3
apps/todo.json Normal file
View File

@ -0,0 +1,3 @@
{
"type": "tildefriends-app"
}

View File

@ -1,7 +1,6 @@
import * as core from './core.js';
import * as form from './form.js';
let gTokens = {};
let gDatabase = new Database("auth");
const kRefreshInterval = 1 * 7 * 24 * 60 * 60 * 1000;

View File

@ -137,7 +137,7 @@ function showFiles() {
}
function trace() {
window.open(`/speedscope/#profileURL=${encodeURIComponent('/trace')}&title=Tilde%20Friends`);
window.open(`/speedscope/#profileURL=${encodeURIComponent('/trace')}`);
}
function stats() {
@ -544,6 +544,9 @@ function _receive_websocket_message(message) {
rpc_in: {group: 'rpc', name: 'in'},
rpc_out: {group: 'rpc', name: 'out'},
cpu_percent: {group: 'cpu', name: 'main'},
thread_percent: {group: 'cpu', name: 'work'},
arena_percent: {group: 'memory', name: 'm'},
js_malloc_percent: {group: 'memory', name: 'js'},
memory_percent: {group: 'memory', name: 'tot'},

View File

@ -38,8 +38,6 @@ let gGlobalSettings = {
index: "/~core/apps/",
};
let kGlobalSettingsFile = "data/global/settings.json";
let kPingInterval = 60 * 1000;
function printError(out, error) {
@ -145,12 +143,12 @@ async function getSessionProcessBlob(blobId, session, options) {
return getProcessBlob(blobId, 'session_' + session, actualOptions);
}
let gManifestCache = {};
async function getProcessBlob(blobId, key, options) {
let process = gProcesses[key];
if (!process
&& !(options && "create" in options && !options.create)) {
let resolveReady;
let rejectReady;
try {
print("Creating task for " + blobId + " " + key);
process = {};
@ -165,8 +163,6 @@ async function getProcessBlob(blobId, key, options) {
process.lastPing = null;
process.timeout = options.timeout;
process.stats = false;
let resolveReady;
let rejectReady;
process.ready = new Promise(function(resolve, reject) {
resolveReady = resolve;
rejectReady = reject;
@ -347,6 +343,20 @@ async function getProcessBlob(blobId, key, options) {
});
}
};
imports.ssb.privateMessageEncrypt = function(id, recipients, message) {
if (process.credentials &&
process.credentials.session &&
process.credentials.session.name) {
return ssb.privateMessageEncrypt(process.credentials.session.name, id, recipients, message);
}
};
imports.ssb.privateMessageDecrypt = function(id, message) {
if (process.credentials &&
process.credentials.session &&
process.credentials.session.name) {
return ssb.privateMessageDecrypt(process.credentials.session.name, id, message);
}
};
if (process.credentials &&
process.credentials.session &&
@ -544,6 +554,9 @@ function sendData(response, data, type, headers) {
} else if (startsWithBytes(data, [0x52, 0x49, 0x46, 0x46, null, null, null, null, 0x57, 0x45, 0x42, 0x50])) {
response.writeHead(200, Object.assign({"Content-Type": "image/webp", "Content-Length": data.byteLength}, headers || {}));
response.end(data);
} else if (startsWithBytes(data, [0x3c, 0x73, 0x76, 0x67])) {
response.writeHead(200, Object.assign({"Content-Type": "image/svg+xml", "Content-Length": data.byteLength}, headers || {}));
response.end(data);
} else if (startsWithBytes(data, [null, null, null, null, 0x66, 0x74, 0x79, 0x70, 0x6d, 0x70, 0x34, 0x32])) {
response.writeHead(200, Object.assign({"Content-Type": "audio/mpeg", "Content-Length": data.byteLength}, headers || {}));
response.end(data);
@ -705,7 +718,7 @@ async function blobHandler(request, response, blobId, uri) {
} catch {
}
if (apps.delete(appName)) {
database.set('apps', JSON.stringify([...apps]));
database.set('apps', JSON.stringify([...apps].sort()));
}
database.remove('path:' + appName);
} else {
@ -769,8 +782,7 @@ ssb.addEventListener('connections', function() {
});
async function loadSettings() {
let data;
let data = {};
try {
let settings = new Database('core').get('settings');
if (settings) {
@ -779,19 +791,7 @@ async function loadSettings() {
} catch (error) {
print("Settings not found in database:", error);
}
if (!data) {
try {
data = JSON.parse(utf8Decode(await File.readFile(kGlobalSettingsFile)));
new Database('core').set('settings', JSON.stringify(data));
} catch (error) {
print("Unable to load settings from " + kGlobalSettingsFile + ":", error);
}
}
if (data) {
gGlobalSettings = data;
}
gGlobalSettings = data;
}
function sendStats() {
@ -850,6 +850,14 @@ loadSettings().then(function() {
let data = JSON.stringify(getDebug(), null, 2);
response.writeHead(200, {"Content-Type": "application/json; charset=utf-8", "Content-Length": data.length.toString()});
return response.end(data);
} else if (match = /^\/mem$/.exec(request.uri)) {
let data = JSON.stringify(getAllocations(), null, 2);
response.writeHead(200, {
"Content-Type": "application/json; charset=utf-8",
"Content-Length": data.length.toString(),
"Access-Control-Allow-Origin": "*",
});
return response.end(data);
} else if (request.uri == "/robots.txt") {
return blobHandler(request, response, null, request.uri);
} else if ((match = /^\/.well-known\/(.*)/.exec(request.uri)) && request.uri.indexOf("..") == -1) {

View File

@ -1,7 +1,7 @@
function decode(encoded) {
var result = "";
for (var i = 0; i < encoded.length; i++) {
var c = encoded[i];
let result = "";
for (let i = 0; i < encoded.length; i++) {
let c = encoded[i];
if (c == "+") {
result += " ";
} else if (c == "%") {
@ -15,15 +15,15 @@ function decode(encoded) {
}
function decodeForm(encoded, initial) {
var result = initial || {};
let result = initial || {};
if (encoded) {
encoded = encoded.trim();
var items = encoded.split('&');
for (var i = 0; i < items.length; i++) {
var item = items[i];
var equals = item.indexOf('=');
var key = decode(item.slice(0, equals));
var value = decode(item.slice(equals + 1));
let items = encoded.split('&');
for (let i = 0; i < items.length; i++) {
let item = items[i];
let equals = item.indexOf('=');
let key = decode(item.slice(0, equals));
let value = decode(item.slice(equals + 1));
result[key] = value;
}
}

View File

@ -456,8 +456,6 @@ function handleConnection(client) {
}
}
client.noDelay = true;
client.onError(function(error) {
logError(client.peerName + " - - [" + new Date() + "] " + error);
});
@ -558,10 +556,14 @@ let kHost = "0.0.0.0"
let socket = new Socket();
socket.bind(kHost, tildefriends.http_port).then(function() {
let listenResult = socket.listen(kBacklog, function() {
socket.accept().then(handleConnection).catch(function(error) {
let listenResult = socket.listen(kBacklog, async function() {
try {
let client = await socket.accept();
client.noDelay = true;
handleConnection(client);
} catch (error) {
logError("[" + new Date() + "] accept error " + error);
});
}
});
}).catch(function(error) {
logError("[" + new Date() + "] bind error " + error);
@ -574,6 +576,7 @@ if (tildefriends.https_port) {
return secureSocket.listen(kBacklog, async function() {
try {
let client = await secureSocket.accept();
client.noDelay = true;
client.tls = true;
const kCertificatePath = "data/httpd/certificate.pem";
const kPrivateKeyPath = "data/httpd/privatekey.pem";

View File

@ -1,106 +0,0 @@
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
# http://www.gnu.org/software/automake
Makefile
Makefile.in
/ar-lib
/mdate-sh
/py-compile
/test-driver
/ylwrap
# http://www.gnu.org/software/autoheader
config.h
# http://www.gnu.org/software/autoconf
autom4te.cache
/autoscan.log
/autoscan-*.log
/aclocal.m4
/compile
/config.guess
/config.h.in
/config.log
/config.status
/config.sub
/configure
/configure.scan
/depcomp
/install-sh
/missing
/stamp-h1
# https://www.gnu.org/software/libtool/
/ltmain.sh
# http://www.gnu.org/software/texinfo
/texinfo.tex
# http://www.gnu.org/software/m4/
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
# vim
*.swp
# project specific
test/gen
test/test[0-9]*
test/.deps

29
deps/base64c/LICENSE vendored
View File

@ -1,29 +0,0 @@
BSD 3-Clause License
Copyright (c) 2018, Sean Hanna
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,2 +0,0 @@
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src test

View File

@ -1,60 +0,0 @@
# base64c
This is primarily just a fork of a base64 decoder from the FreeBSD codebase. It has received a few modifications:
* removed all allocations, you are expected to pass in a buffer that has sufficient space and you will get an error (-1) if you run out of space
* replaced a dynamically generated lookup table with a hardcoded lookup table
* wrote my own unit tests, i'm sure there are tests for freebsd somewhere but i didn't find them
# Embedding
This code is primarily intended to be dropped into an existing code base ( or perhaps using submodules). To do that:
* grab include/base64c.h
* grab src/base64c.h
# Usage
Call base64c_encoding_length() to calculate how big a buffer you need to encode a string. It's somewhere around 4 times the size of the input string. This length includes a null terminator.
```c
char input_string[256];
size_t new_len = base64c_encoding_length( strlen(input_string));
unsigned char *buffer = (unsigned char*)malloc(new_len);
```
Call base64c_encode() to actually encode your input string as base64. It will write to the buffer and return how many characters were written. If there was an error it will return -1.
```c
size_t output_length = base64c_encode(input_string, strlen(input_string), buffer, new_len);
if (output_length == -1) {
int x = 1/0; // ERROR!
}
```
Call base64c_decoding_length() to calculate how big a buffer you need to decode. It comes out to about half the size. This number isn't always exact, but it is close to within a byte or two.
```c
size_t decode_len = base64c_decoding_length( strlen(buffer) );
unsigned char *decoded = (unsigned char*)malloc( decode_len );
```
Call base64c_decode() to decode an encoded base64 string. It will write to the buffer and return how many characters were written. IF there was an error it will return -1. If the string contains invalid number of characters, or has any characters that are not part of the base64 character set an error will be returned.
# Building
You need to bootstrap all the autoconf tools by running ./autogen.sh
You need to have autoconf installed to do this.
Once bootstrapped run ./configure
# Tests
There are tests in the test/ subfolder. They will be built automatically. There is no special test runner. You can run each of the test cases manually to check whether the code is working properly.
# References
(http://web.mit.edu/freebsd/head/contrib/wpa/src/utils/base64.c)
(https://github.com/freebsd/freebsd/blob/master/contrib/wpa/src/utils/base64.c)

View File

@ -1,3 +0,0 @@
#!/bin/sh
aclocal && automake --gnu --add-missing && autoconf

View File

@ -1,22 +0,0 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
BASE64C_VERSION=0.5
AC_PREREQ([2.69])
AC_INIT(base64c, 0.5, hannasm@gmail.com)
AM_INIT_AUTOMAKE(base64c, 0.5)
AC_CONFIG_SRCDIR([include/base64c.h])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
# Checks for library functions.
AC_OUTPUT(Makefile src/Makefile test/Makefile)

View File

@ -1,42 +0,0 @@
#ifndef base64cC_H
#define base64cC_H
#include <stddef.h>
#include <stdint.h>
/**
* base64c_encoding_length - calculate length to allocate for encode
* @len: Length of input string
* Returns: number of bytes required to base64c encode, this includes room for '\0' terminator
*/
size_t base64c_encoding_length(size_t len);
/**
* base64c_decoding_length - calculate length to allocate for decode
* @len: Length of (base64 encoded) input string
* Returns: maximum number of bytes required to decode
*/
size_t base64c_decoding_length(size_t inlen);
/**
* base64c_encode - base64c encode
* @src: Data to be encoded
* @len: Length of the data to be encoded
* @out: Mutable output buffer destination, all encoded bytes will be written to the destination
* @out_len: length of output buffer
* Returns: number of bytes written, or -1 if there was an error
*/
size_t base64c_encode(const unsigned char *src, size_t len, unsigned char* out, const size_t out_len);
/**
* base64c_decode - base64c decode
* @src: Data to be decoded
* @len: Length of the data to be decoded
* @out_len: Pointer to output length variable
* Returns: Allocated buffer of out_len bytes of decoded data,
* or %NULL on failure
*
* Caller is responsible for freeing the returned buffer.
*/
size_t base64c_decode(const unsigned char *src, size_t len, unsigned char *out, const size_t out_len);
#endif

View File

@ -1,3 +0,0 @@
CFLAGS = --pednatic -Wall -stdc99 -O2
LDFLAGS =

View File

@ -1,139 +0,0 @@
#include <string.h>
#include <stdio.h>
/*
* Base64 encoding/decoding (RFC1341)
* Copyright (c) 2005-2011, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
static const unsigned char base64c_table[65] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const unsigned char base64c_dtable[256] = {
/*000*/0x80,/*001*/0x80,/*002*/0x80,/*003*/0x80,/*004*/0x80,/*005*/0x80,/*006*/0x80,/*007*/0x80,/*008*/0x80,/*009*/0x80,/*010*/0x80,/*011*/0x80,/*012*/0x80,/*013*/0x80,/*014*/0x80,/*015*/0x80,/*016*/0x80,/*017*/0x80,/*018*/0x80,/*019*/0x80,
/*020*/0x80,/*021*/0x80,/*022*/0x80,/*023*/0x80,/*024*/0x80,/*025*/0x80,/*026*/0x80,/*027*/0x80,/*028*/0x80,/*029*/0x80,/*030*/0x80,/*031*/0x80,/*032*/0x80,/*033*/0x80,/*034*/0x80,/*035*/0x80,/*036*/0x80,/*037*/0x80,/*038*/0x80,/*039*/0x80,
/*040*/0x80,/*041*/0x80,/*042*/0x80,/*043*/0x3e,/*044*/0x80,/*045*/0x80,/*046*/0x80,/*047*/0x3f,/*048*/0x34,/*049*/0x35,/*050*/0x36,/*051*/0x37,/*052*/0x38,/*053*/0x39,/*054*/0x3a,/*055*/0x3b,/*056*/0x3c,/*057*/0x3d,/*058*/0x80,/*059*/0x80,
/*060*/0x80,/*061*/0x00,/*062*/0x80,/*063*/0x80,/*064*/0x80,/*065*/0x00,/*066*/0x01,/*067*/0x02,/*068*/0x03,/*069*/0x04,/*070*/0x05,/*071*/0x06,/*072*/0x07,/*073*/0x08,/*074*/0x09,/*075*/0x0a,/*076*/0x0b,/*077*/0x0c,/*078*/0x0d,/*079*/0x0e,
/*080*/0x0f,/*081*/0x10,/*082*/0x11,/*083*/0x12,/*084*/0x13,/*085*/0x14,/*086*/0x15,/*087*/0x16,/*088*/0x17,/*089*/0x18,/*090*/0x19,/*091*/0x80,/*092*/0x80,/*093*/0x80,/*094*/0x80,/*095*/0x80,/*096*/0x80,/*097*/0x1a,/*098*/0x1b,/*099*/0x1c,
/*100*/0x1d,/*101*/0x1e,/*102*/0x1f,/*103*/0x20,/*104*/0x21,/*105*/0x22,/*106*/0x23,/*107*/0x24,/*108*/0x25,/*109*/0x26,/*110*/0x27,/*111*/0x28,/*112*/0x29,/*113*/0x2a,/*114*/0x2b,/*115*/0x2c,/*116*/0x2d,/*117*/0x2e,/*118*/0x2f,/*119*/0x30,
/*120*/0x31,/*121*/0x32,/*122*/0x33,/*123*/0x80,/*124*/0x80,/*125*/0x80,/*126*/0x80,/*127*/0x80,/*128*/0x80,/*129*/0x80,/*130*/0x80,/*131*/0x80,/*132*/0x80,/*133*/0x80,/*134*/0x80,/*135*/0x80,/*136*/0x80,/*137*/0x80,/*138*/0x80,/*139*/0x80,
/*140*/0x80,/*141*/0x80,/*142*/0x80,/*143*/0x80,/*144*/0x80,/*145*/0x80,/*146*/0x80,/*147*/0x80,/*148*/0x80,/*149*/0x80,/*150*/0x80,/*151*/0x80,/*152*/0x80,/*153*/0x80,/*154*/0x80,/*155*/0x80,/*156*/0x80,/*157*/0x80,/*158*/0x80,/*159*/0x80,
/*160*/0x80,/*161*/0x80,/*162*/0x80,/*163*/0x80,/*164*/0x80,/*165*/0x80,/*166*/0x80,/*167*/0x80,/*168*/0x80,/*169*/0x80,/*170*/0x80,/*171*/0x80,/*172*/0x80,/*173*/0x80,/*174*/0x80,/*175*/0x80,/*176*/0x80,/*177*/0x80,/*178*/0x80,/*179*/0x80,
/*180*/0x80,/*181*/0x80,/*182*/0x80,/*183*/0x80,/*184*/0x80,/*185*/0x80,/*186*/0x80,/*187*/0x80,/*188*/0x80,/*189*/0x80,/*190*/0x80,/*191*/0x80,/*192*/0x80,/*193*/0x80,/*194*/0x80,/*195*/0x80,/*196*/0x80,/*197*/0x80,/*198*/0x80,/*199*/0x80,
/*200*/0x80,/*201*/0x80,/*202*/0x80,/*203*/0x80,/*204*/0x80,/*205*/0x80,/*206*/0x80,/*207*/0x80,/*208*/0x80,/*209*/0x80,/*210*/0x80,/*211*/0x80,/*212*/0x80,/*213*/0x80,/*214*/0x80,/*215*/0x80,/*216*/0x80,/*217*/0x80,/*218*/0x80,/*219*/0x80,
/*220*/0x80,/*221*/0x80,/*222*/0x80,/*223*/0x80,/*224*/0x80,/*225*/0x80,/*226*/0x80,/*227*/0x80,/*228*/0x80,/*229*/0x80,/*230*/0x80,/*231*/0x80,/*232*/0x80,/*233*/0x80,/*234*/0x80,/*235*/0x80,/*236*/0x80,/*237*/0x80,/*238*/0x80,/*239*/0x80,
/*240*/0x80,/*241*/0x80,/*242*/0x80,/*243*/0x80,/*244*/0x80,/*245*/0x80,/*246*/0x80,/*247*/0x80,/*248*/0x80,/*249*/0x80,/*250*/0x80,/*251*/0x80,/*252*/0x80,/*253*/0x80,/*254*/0x80,/*255*/0x00,
};
size_t base64c_encoding_length(size_t len) {
size_t olen = len * 4 / 3 + 4; /* 3-byte blocks to 4-byte */
olen++; /* nul termination */
if (olen < len)
return 0; /* integer overflow */
return olen;
}
size_t base64c_encode(const unsigned char *src, size_t len,
unsigned char* out, const size_t out_len)
{
unsigned char *pos;
const unsigned char *end, *in;
const unsigned char *out_end = out + out_len;
end = src + len;
in = src;
pos = out;
if (out_len < base64c_encoding_length(len)) { return -1; }
while (end - in >= 3 ) {
*pos++ = base64c_table[in[0] >> 2];
*pos++ = base64c_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
*pos++ = base64c_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
*pos++ = base64c_table[in[2] & 0x3f];
in += 3;
}
if (end - in) {
*pos++ = base64c_table[in[0] >> 2];
if (end - in == 1) {
*pos++ = base64c_table[(in[0] & 0x03) << 4];
*pos++ = '=';
} else {
*pos++ = base64c_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
*pos++ = base64c_table[(in[1] & 0x0f) << 2];
}
*pos++ = '=';
}
*pos = '\0';
return out_len - (out_end-pos);
}
size_t base64c_decoding_length(size_t inlen) {
return inlen / 4 * 3;
}
size_t base64c_decode(const unsigned char *src, size_t len, unsigned char *out, const size_t out_len)
{
if (out == NULL) { return 0; }
if (out_len <= 0) { return 0; }
unsigned char *pos, block[4], tmp;
size_t i, count;
int pad = 0;
if (len == 0 ){
*out = '\0';
return 1;
}
if (len % 4) {
return -1;
}
pos = out;
count = 0;
for (i = 0; i < len; i++) {
if (src[i] == '=') { pad++; }
tmp = base64c_dtable[src[i]];
if (tmp == 0x80) { return -1; }
block[count] = tmp;
count++;
if (count == 4) {
switch (pad) {
case 0:
if ((pos - out) + 3 > out_len) {
return -1;
}
*pos++ = (block[0] << 2) | (block[1] >> 4);
*pos++ = (block[1] << 4) | (block[2] >> 2);
*pos++ = (block[2] << 6) | block[3];
break;
case 1:
if ((pos - out) + 2 > out_len || i + 1 > len) {
return -1;
}
*pos++ = (block[0] << 2) | (block[1] >> 4);
*pos++ = (block[1] << 4) | (block[2] >> 2);
break;
case 2:
if ((pos - out) + 1 > out_len || i + 1 > len) {
return -1;
}
*pos++ = (block[0] << 2) | (block[1] >> 4);
break;
default:
break;
}
count = 0;
}
}
return pos - out;
}

View File

@ -1,16 +0,0 @@
CFLAGS = --pedantic -Wall -std=c99 -g -ggdb
LDFLAGS =
bin_PROGRAMS = test001 test002 test003 test004 \
test005 test006 test007 test008 \
gen
test001_SOURCES = test001.c ../src/base64c.c
test002_SOURCES = test002.c ../src/base64c.c
test003_SOURCES = test003.c ../src/base64c.c
test004_SOURCES = test004.c ../src/base64c.c
test005_SOURCES = test005.c ../src/base64c.c
test006_SOURCES = test006.c ../src/base64c.c
test007_SOURCES = test007.c ../src/base64c.c
test008_SOURCES = test008.c ../src/base64c.c
gen_SOURCES = gen.c

View File

@ -1,22 +0,0 @@
#include <stdio.h>
#include <string.h>
static const unsigned char base64_table[65] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
int main() {
unsigned char out[256];
memset(out, 0x80, 255);
for (int i = 0; i < 64; i++) {
out[base64_table[i]] = i;
}
out['='] = 0;
printf("static const unsigned char base64c_dtable[256] = {");
for (int i = 0; i < 256; i++) {
if (i% 20==0) { printf("\n"); }
printf("/*%03d*/0x%02x,", i, out[i]);
}
printf("\n};");
}

View File

@ -1,36 +0,0 @@
#include "../include/base64c.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
unsigned char in[12] = "Hello World";
size_t in_len = 11;
unsigned char enc[32];
size_t enc_len = 32;
unsigned char out[12];
size_t out_len = 12;
printf("Encoding %lu - %s\n", in_len, in);
size_t enc_result = base64c_encode(in, in_len, enc, enc_len);
printf("Encoded %lu - %s\n", enc_result, enc);
size_t dec_result = base64c_decode(enc, enc_result, out, out_len);
if ((long)dec_result < 0) {
printf("Decode failed with code %ld\n", (long)dec_result);
return 1;
}
printf("Decoded %lu - %s\n", dec_result, out);
if (dec_result != in_len) {
printf("in length %ld not equal to out length %ld", in_len, dec_result);
return 3;
}
if (strncmp((char*)in, (char*)out, in_len)) {
printf("roundtrip encoding failed\n");
return 2;
}
}

View File

@ -1,37 +0,0 @@
#include "../include/base64c.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
unsigned char in[11] = "Hello Worl";
size_t in_len = 10;
unsigned char enc[32];
size_t enc_len = 32;
unsigned char out[12];
size_t out_len = 12;
printf("Encoding %lu - %s\n", in_len, in);
size_t enc_result = base64c_encode(in, in_len, enc, enc_len);
printf("Encoded %lu - %s\n", enc_result, enc);
size_t dec_result = base64c_decode(enc, enc_result, out, out_len);
if ((long)dec_result < 0) {
printf("Decode failed with code %ld\n", (long)dec_result);
return 1;
}
printf("Decoded %lu - %s\n", dec_result, out);
if (dec_result != in_len) {
printf("in length %ld not equal to out length %ld", in_len, dec_result);
return 3;
}
if (strncmp((char*)in, (char*)out, in_len)) {
printf("roundtrip encoding failed\n");
return 2;
}
}

View File

@ -1,37 +0,0 @@
#include "../include/base64c.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
unsigned char in[10] = "Hello Wor";
size_t in_len = 9;
unsigned char enc[32];
size_t enc_len = 32;
unsigned char out[12];
size_t out_len = 12;
printf("Encoding %lu - %s\n", in_len, in);
size_t enc_result = base64c_encode(in, in_len, enc, enc_len);
printf("Encoded %lu - %s\n", enc_result, enc);
size_t dec_result = base64c_decode(enc, enc_result, out, out_len);
if ((long)dec_result < 0) {
printf("Decode failed with code %ld\n", (long)dec_result);
return 1;
}
printf("Decoded %lu - %s\n", dec_result, out);
if (dec_result != in_len) {
printf("in length %ld not equal to out length %ld", in_len, dec_result);
return 3;
}
if (strncmp((char*)in, (char*)out, in_len)) {
printf("roundtrip encoding failed\n");
return 2;
}
}

View File

@ -1,37 +0,0 @@
#include "../include/base64c.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
unsigned char in[10] = "Hello Wo";
size_t in_len = 8;
unsigned char enc[32];
size_t enc_len = 32;
unsigned char out[12];
size_t out_len = 12;
printf("Encoding %lu - %s\n", in_len, in);
size_t enc_result = base64c_encode(in, in_len, enc, enc_len);
printf("Encoded %lu - %s\n", enc_result, enc);
size_t dec_result = base64c_decode(enc, enc_result, out, out_len);
if ((long)dec_result < 0) {
printf("Decode failed with code %ld\n", (long)dec_result);
return 1;
}
printf("Decoded %lu - %s\n", dec_result, out);
if (dec_result != in_len) {
printf("in length %ld not equal to out length %ld", in_len, dec_result);
return 3;
}
if (strncmp((char*)in, (char*)out, in_len)) {
printf("roundtrip encoding failed\n");
return 2;
}
}

View File

@ -1,36 +0,0 @@
#include "../include/base64c.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
unsigned char in[13] = "Hello Worlds";
size_t in_len = 12;
unsigned char enc[32];
size_t enc_len = 32;
unsigned char out[13];
size_t out_len = 13;
printf("Encoding %lu - %s\n", in_len, in);
size_t enc_result = base64c_encode(in, in_len, enc, enc_len);
printf("Encoded %lu - %s\n", enc_result, enc);
size_t dec_result = base64c_decode(enc, enc_result, out, out_len);
if ((long)dec_result < 0) {
printf("Decode failed with code %ld\n", (long)dec_result);
return 1;
}
printf("Decoded %lu - %s\n", dec_result, out);
if (dec_result != in_len) {
printf("in length %ld not equal to out length %ld", in_len, dec_result);
return 3;
}
if (strncmp((char*)in, (char*)out, in_len)) {
printf("roundtrip encoding failed\n");
return 2;
}
}

View File

@ -1,36 +0,0 @@
#include "../include/base64c.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
unsigned char in[14] = "Hello Worldsy";
size_t in_len = 13;
unsigned char enc[32];
size_t enc_len = 32;
unsigned char out[15];
size_t out_len = 15;
printf("Encoding %lu - %s\n", in_len, in);
size_t enc_result = base64c_encode(in, in_len, enc, enc_len);
printf("Encoded %lu - %s\n", enc_result, enc);
size_t dec_result = base64c_decode(enc, enc_result, out, out_len);
if ((long)dec_result < 0) {
printf("Decode failed with code %ld\n", (long)dec_result);
return 1;
}
printf("Decoded %lu - %s\n", dec_result, out);
if (dec_result != in_len) {
printf("in length %ld not equal to out length %ld", in_len, dec_result);
return 3;
}
if (strncmp((char*)in, (char*)out, in_len)) {
printf("roundtrip encoding failed\n");
return 2;
}
}

View File

@ -1,36 +0,0 @@
#include "../include/base64c.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
unsigned char in[15] = "Hello World of";
size_t in_len = 14;
unsigned char enc[32];
size_t enc_len = 32;
unsigned char out[15];
size_t out_len = 15;
printf("Encoding %lu - %s\n", in_len, in);
size_t enc_result = base64c_encode(in, in_len, enc, enc_len);
printf("Encoded %lu - %s\n", enc_result, enc);
size_t dec_result = base64c_decode(enc, enc_result, out, out_len);
if ((long)dec_result < 0) {
printf("Decode failed with code %ld\n", (long)dec_result);
return 1;
}
printf("Decoded %lu - %s\n", dec_result, out);
if (dec_result != in_len) {
printf("in length %ld not equal to out length %ld", in_len, dec_result);
return 3;
}
if (strncmp((char*)in, (char*)out, in_len)) {
printf("roundtrip encoding failed\n");
return 2;
}
}

View File

@ -1,37 +0,0 @@
#include "../include/base64c.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
unsigned char in[10] = "H";
size_t in_len = 1;
unsigned char enc[32];
size_t enc_len = 32;
unsigned char out[12];
size_t out_len = 12;
printf("Encoding %lu - %s\n", in_len, in);
size_t enc_result = base64c_encode(in, in_len, enc, enc_len);
printf("Encoded %lu - %s\n", enc_result, enc);
size_t dec_result = base64c_decode(enc, enc_result, out, out_len);
if ((long)dec_result < 0) {
printf("Decode failed with code %ld\n", (long)dec_result);
return 1;
}
printf("Decoded %lu - %s\n", dec_result, out);
if (dec_result != in_len) {
printf("in length %ld not equal to out length %ld", in_len, dec_result);
return 3;
}
if (strncmp((char*)in, (char*)out, in_len)) {
printf("roundtrip encoding failed\n");
return 2;
}
}

View File

@ -12,13 +12,14 @@ jobs:
tcc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Update packages list
run: sudo apt-get update
- name: Install dependencies
run: sudo apt-get install -y build-essential libtool autoconf automake tcc
run: |
sudo apt-get install -y build-essential libtool autoconf automake tcc
- name: Autogen
run: ./autogen.sh -s
@ -31,10 +32,40 @@ jobs:
make uninstall
make distclean
zig:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update packages list
run: sudo apt-get update
- name: Install dependencies
run: |
curl -sL -o - https://ziglang.org/download/0.10.1/zig-linux-x86_64-0.10.1.tar.xz | tar xJ -f - -C /opt/
sudo mv /opt/zig-* /opt/zig
- name: Autogen
run: ./autogen.sh -s
- name: Compilation with zig
run: |
export PATH=/opt/zig:$PATH
zig build
zig build -Dtarget=x86_64-linux
zig build -Dtarget=aarch64-linux
zig build -Dtarget=x86_64-windows
zig build -Dtarget=aarch64-windows
zig build -Dtarget=x86_64-macos
zig build -Dtarget=aarch64-macos
zig build -Dtarget=wasm32-wasi
zig build -Drelease-fast
rm -fr zig-cache zig-out
regular:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Update packages list
run: sudo apt-get update
@ -63,7 +94,7 @@ jobs:
check-globals:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Update packages list
run: sudo apt-get update
@ -81,7 +112,7 @@ jobs:
other-comp:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Update packages list
run: sudo apt-get update
@ -107,7 +138,7 @@ jobs:
other-arch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Update packages list
run: sudo apt-get update
@ -123,3 +154,28 @@ jobs:
env CPPFLAGS="-DDEV_MODE=1" ./configure --disable-dependency-tracking --host=powerpc-linux-gnu
make -j $(nproc)
make clean > /dev/null
android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Update packages list
run: sudo apt-get update
- name: Install base dependencies
run: sudo apt-get install -y libtool autoconf automake unzip
- name: Autogen
run: ./autogen.sh -s
- name: Install Android NDK
run: |
mkdir /tmp/android && cd /tmp/android
curl -o ndk.zip -L https://dl.google.com/android/repository/android-ndk-r25b-linux.zip
unzip ndk.zip && rm -f *.zip && mv android-ndk* ndk
- name: Android compilation
run: |
env ANDROID_NDK_HOME=/tmp/android/ndk ./dist-build/android-x86.sh
env ANDROID_NDK_HOME=/tmp/android/ndk ./dist-build/android-armv8-a.sh

View File

@ -12,12 +12,12 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: cpp
@ -27,4 +27,4 @@ jobs:
make -j $(nproc) check
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

View File

@ -10,187 +10,182 @@ jobs:
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: buildbase.bat
run: buildbase.bat ..\vs2022\libsodium.sln 17
working-directory: builds/msvc/build/
shell: cmd
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: build-win-x64
path: bin/x64/Release/v143/dynamic/libsodium.dll
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: build-win-x86
path: bin/Win32/Release/v143/dynamic/libsodium.dll
build-linux-glibc:
runs-on: ubuntu-latest
container:
image: ubuntu:16.04
steps:
- name: Set up build environment
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: 0.10.1
- uses: actions/checkout@v3
- name: build
run: |
apt-get update && apt-get install -y build-essential
- uses: actions/checkout@v1
- name: configure
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build
- name: make
run: make
- name: make check
run: make check
- name: make install
run: make install
- name: strip
run: strip --strip-all .libsodium-build/lib/libsodium.so
- uses: actions/upload-artifact@v2
zig build -Drelease-fast -Dtarget=x86_64-linux-gnu.2.17
- name: tests
run: cd zig-out/bin && ./run.sh
- uses: actions/upload-artifact@v3
with:
name: build-linux-x64
path: .libsodium-build/lib/libsodium.so
path: zig-out/lib/libsodium.so
build-linux-glibc-arm:
runs-on: ubuntu-latest
steps:
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: 0.10.1
- name: Fix ARM support
run: |
curl -L https://raw.githubusercontent.com/ziglang/zig/master/lib/libc/glibc/sysdeps/arm/arm-features.h | sudo tee /opt/hostedtoolcache/zig/zig-linux-x86_64-*/x64/lib/libc/glibc/sysdeps/arm/sysdep.h >/dev/null
- name: Set up emulation environment
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y build-essential qemu binfmt-support qemu-user-static qemu-system-arm gcc-arm-linux-gnueabihf libc6-armhf-cross
sudo dpkg --add-architecture armhf
sudo update-binfmts --enable qemu-arm
sudo update-binfmts --display
sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.* /lib
- uses: actions/checkout@v3
- name: build
run: |
zig build -Drelease-fast -Dtarget=arm-linux-gnueabihf.2.23
- name: tests
run: |
cd zig-out/bin && env LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/lib ./run.sh
- uses: actions/upload-artifact@v3
with:
name: build-linux-arm
path: zig-out/lib/libsodium.so
build-linux-glibc-arm64:
runs-on: ubuntu-latest
container:
image: ubuntu:16.04
steps:
- name: Set up build environment
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: 0.10.1
- name: Set up emulation environment
run: |
export DEBIAN_FRONTEND=noninteractive
cat <<-EOF | tee /etc/apt/sources.list.d/arm64.list >/dev/null
deb [arch=arm64] http://ports.ubuntu.com/ xenial main restricted
deb [arch=arm64] http://ports.ubuntu.com/ xenial-updates main restricted
deb [arch=arm64] http://ports.ubuntu.com/ xenial universe
deb [arch=arm64] http://ports.ubuntu.com/ xenial-updates universe
deb [arch=arm64] http://ports.ubuntu.com/ xenial multiverse
deb [arch=arm64] http://ports.ubuntu.com/ xenial-updates multiverse
deb [arch=arm64] http://ports.ubuntu.com/ xenial-backports main restricted universe multiverse
EOF
sed -i 's/deb h/deb [arch=amd64] h/g' /etc/apt/sources.list
dpkg --add-architecture arm64
apt-get update && apt-get install -y build-essential qemu-user qemu-user-static gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libstdc++6:arm64
- uses: actions/checkout@v1
- name: configure
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build --host=aarch64-linux-gnu
- name: make
run: make -j $(nproc)
- name: make check
# Disable make check on this platform
if: ${{ false }}
sudo apt-get update
sudo apt-get install -y qemu binfmt-support qemu-user-static qemu-system-arm gcc-aarch64-linux-gnu libc6-arm64-cross
sudo dpkg --add-architecture arm64
sudo update-binfmts --enable qemu-aarch64
sudo update-binfmts --display
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.* /lib
- uses: actions/checkout@v3
- name: build
run: |
make check
- name: make install
run: make install
- name: strip
run: aarch64-linux-gnu-strip --strip-all .libsodium-build/lib/libsodium.so
- uses: actions/upload-artifact@v2
zig build -Drelease-fast -Dtarget=aarch64-linux-gnu.2.23
- name: tests
run: |
cd zig-out/bin && env LD_LIBRARY_PATH=/usr/aarch64-linux-gnu/lib ./run.sh
- uses: actions/upload-artifact@v3
with:
name: build-linux-arm64
path: .libsodium-build/lib/libsodium.so
build-linux-glibc-arm:
runs-on: ubuntu-20.04
steps:
- name: Set up build environment
run: |
export DEBIAN_FRONTEND=noninteractive
cat <<-EOF | sudo tee /etc/apt/sources.list.d/armhf.list >/dev/null
deb [arch=armhf] http://ports.ubuntu.com/ focal main restricted
deb [arch=armhf] http://ports.ubuntu.com/ focal-updates main restricted
deb [arch=armhf] http://ports.ubuntu.com/ focal universe
deb [arch=armhf] http://ports.ubuntu.com/ focal-updates universe
deb [arch=armhf] http://ports.ubuntu.com/ focal multiverse
deb [arch=armhf] http://ports.ubuntu.com/ focal-updates multiverse
deb [arch=armhf] http://ports.ubuntu.com/ focal-backports main restricted universe multiverse
EOF
sudo sed -i 's/deb h/deb [arch=amd64] h/g' /etc/apt/sources.list
sudo dpkg --add-architecture armhf
sudo apt-get update && sudo apt-get install -y build-essential qemu-user qemu-user-static gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libstdc++6:armhf
- uses: actions/checkout@v1
- name: configure
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build --host=arm-linux-gnueabihf
- name: make
run: make -j $(nproc)
- name: make check
run: |
make check
- name: make install
run: make install
- name: strip
run: arm-linux-gnueabihf-strip --strip-all .libsodium-build/lib/libsodium.so
- uses: actions/upload-artifact@v2
with:
name: build-linux-arm
path: .libsodium-build/lib/libsodium.so
path: zig-out/lib/libsodium.so
build-linux-musl:
runs-on: ubuntu-latest
container:
image: alpine:3.15
image: alpine:3.13
steps:
- name: Set up build environment
run: |
apk update
apk add alpine-sdk ca-certificates
- uses: actions/checkout@v1
- name: configure
run: ./configure --disable-dependency-tracking --prefix=$PWD/.libsodium-build
- name: make
run: make
- name: make check
run: make check
- name: make install
run: make install
- name: strip
run: strip --strip-all .libsodium-build/lib/libsodium.so
- uses: actions/upload-artifact@v2
apk add alpine-sdk ca-certificates xz
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: 0.10.1
- uses: actions/checkout@v3
- name: build
run: |
zig build -Drelease-fast -Dtarget=x86_64-linux-musl
- name: tests
run: |
cd zig-out/bin && ./run.sh
- uses: actions/upload-artifact@v3
with:
name: build-linux-musl-x64
path: .libsodium-build/lib/libsodium.so
path: zig-out/lib/libsodium.so
build-linux-musl-arm:
runs-on: ubuntu-latest
steps:
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: 0.10.1
- uses: actions/checkout@v3
- name: build
run: |
zig build -Drelease-fast -Dtarget=arm-linux-musleabihf
- uses: actions/upload-artifact@v3
with:
name: build-linux-musl-arm
path: zig-out/lib/libsodium.so
build-linux-musl-arm64:
runs-on: ubuntu-latest
steps:
- name: Install Zig
uses: goto-bus-stop/setup-zig@869a4299cf8ac7db4ebffaec36ad82a682f88acb
with:
version: 0.10.1
- uses: actions/checkout@v3
- name: build
run: |
zig build -Drelease-fast -Dtarget=aarch64-linux-musl
- uses: actions/upload-artifact@v3
with:
name: build-linux-musl-arm64
path: zig-out/lib/libsodium.so
build-macos-x64:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: configure
run: env CFLAGS="-O2 -arch x86_64 -mmacosx-version-min=10.10" LDFLAGS="-arch x86_64 -mmacosx-version-min=10.10" ./configure --host=arm-apple-darwin20 --prefix=$PWD/.libsodium-build
run: env CFLAGS="-Ofast -arch x86_64 -mmacosx-version-min=10.15" LDFLAGS="-arch x86_64 -mmacosx-version-min=10.15" ./configure --host=arm-apple-darwin20 --prefix=$PWD/.libsodium-build
- name: make
run: make
- name: make check
run: make check
- name: make install
run: make install
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: build-osx-x64
path: .libsodium-build/lib/libsodium.dylib
build-macos-arm64:
runs-on: macos-11
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: configure
run: env CFLAGS="-O2 -arch arm64 -mmacosx-version-min=10.10" LDFLAGS="-arch arm64 -mmacosx-version-min=10.10" ./configure --host=arm-apple-darwin20 --prefix=$PWD/.libsodium-build
run: env CFLAGS="-Ofast -arch arm64 -mmacosx-version-min=10.15" LDFLAGS="-arch arm64 -mmacosx-version-min=10.15" ./configure --host=arm-apple-darwin20 --prefix=$PWD/.libsodium-build
- name: make
run: make
- name: make install
run: make install
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: build-osx-arm64
path: .libsodium-build/lib/libsodium.dylib
@ -203,6 +198,8 @@ jobs:
- build-linux-glibc-arm
- build-linux-glibc-arm64
- build-linux-musl
- build-linux-musl-arm
- build-linux-musl-arm64
- build-macos-x64
- build-macos-arm64
container:
@ -212,36 +209,44 @@ jobs:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
steps:
- uses: actions/checkout@v1
- uses: actions/download-artifact@v2
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: build-win-x64
path: .libsodium-pack/runtimes/win-x64/native/
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: build-win-x86
path: .libsodium-pack/runtimes/win-x86/native/
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: build-linux-x64
path: .libsodium-pack/runtimes/linux-x64/native/
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: build-linux-arm64
path: .libsodium-pack/runtimes/linux-arm64/native/
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: build-linux-arm
path: .libsodium-pack/runtimes/linux-arm/native/
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: build-linux-musl-x64
path: .libsodium-pack/runtimes/linux-musl-x64/native/
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: build-linux-musl-arm
path: .libsodium-pack/runtimes/linux-musl-arm/native/
- uses: actions/download-artifact@v3
with:
name: build-linux-musl-arm64
path: .libsodium-pack/runtimes/linux-musl-arm64/native/
- uses: actions/download-artifact@v3
with:
name: build-osx-x64
path: .libsodium-pack/runtimes/osx-x64/native/
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: build-osx-arm64
path: .libsodium-pack/runtimes/osx-arm64/native/
@ -249,7 +254,7 @@ jobs:
run: cp AUTHORS ChangeLog LICENSE packaging/dotnet-core/libsodium.pkgproj .libsodium-pack/
- name: Create NuGet package
run: dotnet pack -c Release .libsodium-pack/libsodium.pkgproj
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: nuget-package
path: .libsodium-pack/bin/Release/*.nupkg
@ -265,8 +270,8 @@ jobs:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
steps:
- uses: actions/checkout@v1
- uses: actions/download-artifact@v2
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: nuget-package
path: .libsodium-pack/
@ -291,7 +296,7 @@ jobs:
mv .libsodium-test/bin/Release/net6.0/linux-arm/publish .libsodium-builds/linux-arm
mv .libsodium-test/bin/Release/net6.0/linux-arm64/publish .libsodium-builds/linux-arm64
mv .libsodium-test/bin/Release/net6.0/linux-x64/publish .libsodium-builds/linux-x64
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: test-builds
path: .libsodium-builds/*
@ -302,14 +307,14 @@ jobs:
- build-test-binaries
strategy:
matrix:
# CentOS 7 and Debian 9 use an older GCC version; make sure we can run on those platforms.
arch: [ 'centos:7', 'debian:9' ]
# CentOS 7 and Debian 10 use an older GCC version; make sure we can run on those platforms.
arch: [ 'centos:7', 'debian:10' ]
container:
image: ${{ matrix.arch }}
env:
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: test-builds
path: .libsodium-builds/
@ -319,37 +324,42 @@ jobs:
.libsodium-builds/linux-x64/Tests
run-test-binaries-cross-plat:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs:
- build-test-binaries
env:
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: 1
strategy:
matrix:
include:
- arch: x64
libs: /usr/lib
- arch: arm
libs: /usr/arm-linux-gnueabihf/lib
- arch: arm64
libs: /usr/aarch64-linux-gnu/lib
arch: [x64, arm, arm64]
steps:
- name: Set up build environment
run: |
export DEBIAN_FRONTEND=noninteractive
cat <<-EOF | sudo tee /etc/apt/sources.list.d/multiarch.list >/dev/null
deb [arch=armhf,arm64] http://ports.ubuntu.com/ focal main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ focal-updates main restricted
deb [arch=armhf,arm64] http://ports.ubuntu.com/ focal universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ focal-updates universe
deb [arch=armhf,arm64] http://ports.ubuntu.com/ focal multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ focal-updates multiverse
deb [arch=armhf,arm64] http://ports.ubuntu.com/ focal-backports main restricted universe multiverse
EOF
sudo sed -i 's/deb h/deb [arch=amd64] h/g' /etc/apt/sources.list
# On virtualization systems such as the one used by WSL2, the ARM crypto extensions
# don't work as expected. As a result, installing on Ubuntu fails during integrity
# checks. As a workaround, the following command disables hardware acceleration for
# gcrypt, which the apt-get command relies on.
sudo mkdir -p /etc/gcrypt && echo all | sudo tee /etc/gcrypt/hwf.deny
sudo apt-get update && sudo apt-get install -y qemu binfmt-support qemu-user-static qemu-system-arm gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu libc6-armhf-cross libc6-arm64-cross
sudo dpkg --add-architecture armhf
sudo dpkg --add-architecture arm64
sudo update-binfmts --enable qemu-aarch64
sudo update-binfmts --enable qemu-arm
sudo update-binfmts --display
sudo ln -s /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.* /lib
sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.* /lib
sudo apt-get update && sudo apt-get install -y qemu-user qemu-user-static libstdc++6:armhf libstdc++6:arm64
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: test-builds
path: .libsodium-builds/
@ -357,4 +367,4 @@ jobs:
- name: Run ${{ matrix.arch }}
run: |
chmod +x .libsodium-builds/linux-${{ matrix.arch }}/Tests
.libsodium-builds/linux-${{ matrix.arch }}/Tests
env LD_LIBRARY_PATH=${{ matrix.libs }} .libsodium-builds/linux-${{ matrix.arch }}/Tests

View File

@ -45,8 +45,7 @@ siphash Jean-Philippe Aumasson
Implementors
============
crypto_aead/aes256gcm/aesni Romain Dolbeau
Frank Denis
crypto_aead/aes256gcm/aesni Frank Denis
crypto_aead/chacha20poly1305 Frank Denis

View File

@ -1,7 +1,7 @@
/*
* ISC License
*
* Copyright (c) 2013-2022
* Copyright (c) 2013-2023
* Frank Denis <j at pureftpd dot org>
*
* Permission to use, copy, modify, and/or distribute this software for any

View File

@ -16,12 +16,13 @@ jobs:
curl https://get.wasmer.io -sSfL | sh
displayName: Install wasmer
- script: |
curl -sL -o - https://ziglang.org/download/0.8.1/zig-linux-x86_64-0.8.1.tar.xz | tar xJ -f - -C /opt/
curl -sL -o - https://ziglang.org/download/0.10.1/zig-linux-x86_64-0.10.1.tar.xz | tar xJ -f - -C /opt/
sudo mv /opt/zig-* /opt/zig
env PATH=/opt/zig/bin:/opt/zig:$PATH
export PATH=/opt/zig/bin:/opt/zig:$PATH
displayName: Install the Zig SDK
- script: |
env WASMER_DIR=${HOME}/.wasmer PATH=${HOME}/.wasmer/bin:${HOME}/.cargo/bin:$PATH dist-build/wasm32-wasi.sh
. ~/.wasmer/wasmer.sh
dist-build/wasm32-wasi.sh
displayName: Compile libsodium
- task: PublishBuildArtifacts@1
condition: not(canceled())
@ -67,26 +68,12 @@ jobs:
pathToPublish: bin
artifactName: libsodium
- job: "windows_old"
pool:
vmImage: "vs2017-win2016"
steps:
- powershell: |
cd builds\msvc\build
& .\buildbase.bat ..\vs2017\libsodium.sln 15
displayName: Compile it all
- task: PublishBuildArtifacts@1
condition: not(canceled())
inputs:
pathToPublish: bin
artifactName: libsodium
- job: mingw64
pool:
vmImage: "windows-2019"
steps:
- powershell: |
(New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2021-07-25/msys2-base-x86_64-20210725.sfx.exe", "sfx.exe")
(New-Object Net.WebClient).DownloadFile("https://github.com/msys2/msys2-installer/releases/download/2022-12-16/msys2-base-x86_64-20221216.sfx.exe", "sfx.exe")
.\sfx.exe -y -o\
del sfx.exe
displayName: Install MSYS2

View File

@ -1,10 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright 1992-2022 Free Software Foundation, Inc.
# Copyright 1992-2023 Free Software Foundation, Inc.
# shellcheck disable=SC2006,SC2268 # see below for rationale
timestamp='2022-01-03'
timestamp='2023-01-21'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@ -76,7 +76,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright 1992-2022 Free Software Foundation, Inc.
Copyright 1992-2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -145,7 +145,7 @@ case $1 in
nto-qnx* | linux-* | uclinux-uclibc* \
| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
| storm-chaos* | os2-emx* | rtmk-nova*)
| storm-chaos* | os2-emx* | rtmk-nova* | managarm-*)
basic_machine=$field1
basic_os=$maybe_os
;;
@ -1075,7 +1075,7 @@ case $cpu-$vendor in
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
cpu=i586
;;
pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
cpu=i686
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
@ -1207,7 +1207,7 @@ case $cpu-$vendor in
| k1om \
| le32 | le64 \
| lm32 \
| loongarch32 | loongarch64 | loongarchx32 \
| loongarch32 | loongarch64 \
| m32c | m32r | m32rle \
| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
@ -1341,6 +1341,10 @@ EOF
kernel=linux
os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
;;
managarm*)
kernel=managarm
os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
;;
*)
kernel=
os=$basic_os
@ -1754,7 +1758,7 @@ case $os in
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
| fiwix* )
| fiwix* | mlibc* )
;;
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
@ -1762,6 +1766,9 @@ case $os in
;;
none)
;;
kernel* )
# Restricted further below
;;
*)
echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
exit 1
@ -1772,16 +1779,26 @@ esac
# (given a valid OS), if there is a kernel.
case $kernel-$os in
linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
| linux-musl* | linux-relibc* | linux-uclibc* )
| linux-musl* | linux-relibc* | linux-uclibc* | linux-mlibc* )
;;
uclinux-uclibc* )
;;
-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
managarm-mlibc* | managarm-kernel* )
;;
-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* | -mlibc* )
# These are just libc implementations, not actual OSes, and thus
# require a kernel.
echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
exit 1
;;
-kernel* )
echo "Invalid configuration \`$1': \`$os' needs explicit kernel." 1>&2
exit 1
;;
*-kernel* )
echo "Invalid configuration \`$1': \`$kernel' does not support \`$os'." 1>&2
exit 1
;;
kfreebsd*-gnu* | kopensolaris*-gnu*)
;;
vxworks-simlinux | vxworks-simwindows | vxworks-spe)

View File

@ -1,30 +1,38 @@
const std = @import("std");
const builtin = @import("builtin");
const fmt = std.fmt;
const fs = std.fs;
const heap = std.heap;
const mem = std.mem;
const LibExeObjStep = std.build.LibExeObjStep;
const Target = std.Target;
pub fn build(b: *std.build.Builder) !void {
const src_path = "src/libsodium";
const src_dir = try fs.Dir.openDir(fs.cwd(), src_path, .{ .iterate = true, .no_follow = true });
const src_dir = try fs.Dir.openIterableDir(fs.cwd(), src_path, .{ .no_follow = true });
var target = b.standardTargetOptions(.{});
var mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const enable_benchmarks = b.option(bool, "enable_benchmarks", "Whether tests should be benchmarks.") orelse false;
const benchmarks_iterations = b.option(u32, "iterations", "Number of iterations for benchmarks.") orelse 200;
const shared = b.addSharedLibrary(
if (target.isWindows()) "sodium_shared" else "sodium",
null,
.unversioned,
);
const static = b.addStaticLibrary("sodium", null);
const shared = b.addSharedLibrary("sodium", null, .unversioned);
shared.strip = true;
static.strip = true;
const libs = [_]*LibExeObjStep{ static, shared };
const libs_ = [_]*LibExeObjStep{ shared, static };
const libs = if (target.getOsTag() == .wasi) libs_[1..] else libs_[0..];
const prebuilt_version_file_path = "builds/msvc/version.h";
const version_file_path = "include/sodium/version.h";
if (src_dir.access(version_file_path, .{ .mode = .read_only })) {} else |_| {
try fs.cwd().copyFile(prebuilt_version_file_path, src_dir, version_file_path, .{});
if (src_dir.dir.access(version_file_path, .{ .mode = .read_only })) {} else |_| {
try fs.cwd().copyFile(prebuilt_version_file_path, src_dir.dir, version_file_path, .{});
}
for (libs) |lib| {
@ -36,13 +44,95 @@ pub fn build(b: *std.build.Builder) !void {
}
lib.linkLibC();
lib.addIncludeDir("src/libsodium/include/sodium");
lib.addIncludePath("src/libsodium/include/sodium");
lib.defineCMacro("_GNU_SOURCE", "1");
lib.defineCMacro("CONFIGURED", "1");
lib.defineCMacro("DEV_MODE", "1");
lib.defineCMacro("_GNU_SOURCE", "1");
lib.defineCMacro("HAVE_INLINE_ASM", "1");
lib.defineCMacro("HAVE_TI_MODE", "1");
lib.defineCMacro("HAVE_ATOMIC_OPS", "1");
lib.defineCMacro("HAVE_C11_MEMORY_FENCES", "1");
lib.defineCMacro("HAVE_GCC_MEMORY_FENCES", "1");
lib.defineCMacro("HAVE_INLINE_ASM", "1");
lib.defineCMacro("HAVE_INTTYPES_H", "1");
lib.defineCMacro("HAVE_STDINT_H", "1");
lib.defineCMacro("HAVE_TI_MODE", "1");
if (target.cpu_arch) |arch| {
switch (arch.endian()) {
.Big => lib.defineCMacro("NATIVE_BIG_ENDIAN", "1"),
.Little => lib.defineCMacro("NATIVE_LITTLE_ENDIAN", "1"),
}
}
switch (target.getOsTag()) {
.linux => {
lib.defineCMacro("ASM_HIDE_SYMBOL", ".hidden");
lib.defineCMacro("TLS", "_Thread_local");
lib.defineCMacro("HAVE_CATCHABLE_ABRT", "1");
lib.defineCMacro("HAVE_CATCHABLE_SEGV", "1");
lib.defineCMacro("HAVE_CLOCK_GETTIME", "1");
lib.defineCMacro("HAVE_GETPID", "1");
lib.defineCMacro("HAVE_INLINE_ASM", "1");
lib.defineCMacro("HAVE_MADVISE", "1");
lib.defineCMacro("HAVE_MLOCK", "1");
lib.defineCMacro("HAVE_MMAP", "1");
lib.defineCMacro("HAVE_MPROTECT", "1");
lib.defineCMacro("HAVE_NANOSLEEP", "1");
lib.defineCMacro("HAVE_POSIX_MEMALIGN", "1");
lib.defineCMacro("HAVE_PTHREAD_PRIO_INHERIT", "1");
lib.defineCMacro("HAVE_PTHREAD", "1");
lib.defineCMacro("HAVE_RAISE", "1");
lib.defineCMacro("HAVE_SYSCONF", "1");
lib.defineCMacro("HAVE_SYS_AUXV_H", "1");
lib.defineCMacro("HAVE_SYS_MMAN_H", "1");
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
lib.defineCMacro("HAVE_SYS_RANDOM_H", "1");
lib.defineCMacro("HAVE_WEAK_SYMBOLS", "1");
},
.windows => {
lib.defineCMacro("HAVE_RAISE", "1");
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
},
.macos => {
lib.defineCMacro("ASM_HIDE_SYMBOL", ".private_extern");
lib.defineCMacro("TLS", "_Thread_local");
lib.defineCMacro("HAVE_ARC4RANDOM", "1");
lib.defineCMacro("HAVE_ARC4RANDOM_BUF", "1");
lib.defineCMacro("HAVE_CATCHABLE_ABRT", "1");
lib.defineCMacro("HAVE_CATCHABLE_SEGV", "1");
lib.defineCMacro("HAVE_CLOCK_GETTIME", "1");
lib.defineCMacro("HAVE_GETENTROPY", "1");
lib.defineCMacro("HAVE_GETPID", "1");
lib.defineCMacro("HAVE_MADVISE", "1");
lib.defineCMacro("HAVE_MEMSET_S", "1");
lib.defineCMacro("HAVE_MLOCK", "1");
lib.defineCMacro("HAVE_MMAP", "1");
lib.defineCMacro("HAVE_MPROTECT", "1");
lib.defineCMacro("HAVE_NANOSLEEP", "1");
lib.defineCMacro("HAVE_POSIX_MEMALIGN", "1");
lib.defineCMacro("HAVE_PTHREAD", "1");
lib.defineCMacro("HAVE_PTHREAD_PRIO_INHERIT", "1");
lib.defineCMacro("HAVE_RAISE", "1");
lib.defineCMacro("HAVE_SYSCONF", "1");
lib.defineCMacro("HAVE_SYS_MMAN_H", "1");
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
lib.defineCMacro("HAVE_SYS_RANDOM_H", "1");
lib.defineCMacro("HAVE_WEAK_SYMBOLS", "1");
},
.wasi => {
lib.defineCMacro("HAVE_ARC4RANDOM", "1");
lib.defineCMacro("HAVE_ARC4RANDOM_BUF", "1");
lib.defineCMacro("HAVE_CLOCK_GETTIME", "1");
lib.defineCMacro("HAVE_GETENTROPY", "1");
lib.defineCMacro("HAVE_NANOSLEEP", "1");
lib.defineCMacro("HAVE_POSIX_MEMALIGN", "1");
lib.defineCMacro("HAVE_SYS_AUXV_H", "1");
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
lib.defineCMacro("HAVE_SYS_RANDOM_H", "1");
},
else => {},
}
switch (target.getCpuArch()) {
.x86_64 => {
@ -52,9 +142,17 @@ pub fn build(b: *std.build.Builder) !void {
lib.defineCMacro("HAVE_MMINTRIN_H", "1");
lib.defineCMacro("HAVE_EMMINTRIN_H", "1");
lib.defineCMacro("HAVE_PMMINTRIN_H", "1");
lib.defineCMacro("HAVE_SMMINTRIN_H", "1");
lib.defineCMacro("HAVE_TMMINTRIN_H", "1");
lib.defineCMacro("HAVE_WMMINTRIN_H", "1");
},
.aarch64, .aarch64_be => {
lib.defineCMacro("HAVE_ARMCRYTO", "1");
const cpu_features = target.getCpuFeatures();
const has_neon = cpu_features.isEnabled(@enumToInt(Target.aarch64.Feature.neon));
const has_crypto = cpu_features.isEnabled(@enumToInt(Target.aarch64.Feature.crypto));
if (has_neon and has_crypto) {
lib.defineCMacro("HAVE_ARMCRYPTO", "1");
}
},
.wasm32, .wasm64 => {
lib.defineCMacro("__wasm__", "1");
@ -69,6 +167,15 @@ pub fn build(b: *std.build.Builder) !void {
else => {},
}
switch (target.getCpuArch()) {
.x86_64 => {
lib.target.cpu_features_add.addFeature(@enumToInt(Target.x86.Feature.sse4_1));
lib.target.cpu_features_add.addFeature(@enumToInt(Target.x86.Feature.aes));
lib.target.cpu_features_add.addFeature(@enumToInt(Target.x86.Feature.pclmul));
},
else => {},
}
var allocator = heap.page_allocator;
var walker = try src_dir.walk(allocator);
while (try walker.next()) |entry| {
@ -88,4 +195,43 @@ pub fn build(b: *std.build.Builder) !void {
}
}
}
const test_path = "test/default";
const out_bin_path = "zig-out/bin";
const test_dir = try fs.Dir.openIterableDir(fs.cwd(), test_path, .{ .no_follow = true });
fs.Dir.makePath(fs.cwd(), out_bin_path) catch {};
const out_bin_dir = try fs.Dir.openDir(fs.cwd(), out_bin_path, .{});
try test_dir.dir.copyFile("run.sh", out_bin_dir, "run.sh", .{});
var allocator = heap.page_allocator;
var walker = try test_dir.walk(allocator);
while (try walker.next()) |entry| {
const name = entry.basename;
if (mem.endsWith(u8, name, ".exp")) {
try test_dir.dir.copyFile(name, out_bin_dir, name, .{});
continue;
}
if (!mem.endsWith(u8, name, ".c")) {
continue;
}
const exe_name = name[0 .. name.len - 2];
var exe = b.addExecutable(exe_name, null);
exe.setTarget(target);
exe.setBuildMode(mode);
exe.linkLibC();
exe.want_lto = false;
exe.strip = true;
exe.linkLibrary(static);
exe.addIncludePath("src/libsodium/include");
exe.addIncludePath("test/quirks");
const full_path = try fmt.allocPrint(allocator, "{s}/{s}", .{ test_path, entry.path });
exe.addCSourceFiles(&.{full_path}, &.{});
if (enable_benchmarks) {
exe.defineCMacro("BENCHMARKS", "1");
var buf: [16]u8 = undefined;
exe.defineCMacro("ITERATIONS", std.fmt.bufPrintIntToSlice(&buf, benchmarks_iterations, 10, .lower, .{}));
}
exe.install();
}
}

View File

@ -12,7 +12,7 @@
<ItemDefinitionGroup>
<ClCompile>
<DebugInformationFormat>OldStyle</DebugInformationFormat>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<LinkIncremental>true</LinkIncremental>
</ClCompile>

View File

@ -14,7 +14,7 @@
<ItemDefinitionGroup>
<ClCompile>
<AdditionalOptions>/Oy- %(AdditionalOptions)</AdditionalOptions>
<!--<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>-->
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>

View File

@ -1596,7 +1596,7 @@ Some influential environment variables:
CPP C preprocessor
SAFECODE_HOME
set to the safecode base directory
CWFLAGS define to compilation flags for generating extra warnings
CWFLAGS compilation flags for generating extra warnings
LT_SYS_LIBRARY_PATH
User-defined run-time library search path.
AR path to the ar utility
@ -3753,6 +3753,9 @@ then :
fi
sodium_CFLAGS=${CFLAGS+set}
: ${CFLAGS=""}
@ -5289,6 +5292,206 @@ fi
if test "$sodium_CFLAGS" != "set" ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Ofast" >&5
printf %s "checking whether C compiler accepts -Ofast... " >&6; }
if test ${ax_cv_check_cflags___Ofast+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -Ofast"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <time.h>
int
main (void)
{
time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ax_cv_check_cflags___Ofast=yes
else $as_nop
ax_cv_check_cflags___Ofast=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Ofast" >&5
printf "%s\n" "$ax_cv_check_cflags___Ofast" >&6; }
if test "x$ax_cv_check_cflags___Ofast" = xyes
then :
CFLAGS="$CFLAGS -Ofast"
else $as_nop
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -O3" >&5
printf %s "checking whether C compiler accepts -O3... " >&6; }
if test ${ax_cv_check_cflags___O3+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -O3"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <time.h>
int
main (void)
{
time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ax_cv_check_cflags___O3=yes
else $as_nop
ax_cv_check_cflags___O3=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___O3" >&5
printf "%s\n" "$ax_cv_check_cflags___O3" >&6; }
if test "x$ax_cv_check_cflags___O3" = xyes
then :
CFLAGS="$CFLAGS -O3"
else $as_nop
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -O2" >&5
printf %s "checking whether C compiler accepts -O2... " >&6; }
if test ${ax_cv_check_cflags___O2+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -O2"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <time.h>
int
main (void)
{
time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ax_cv_check_cflags___O2=yes
else $as_nop
ax_cv_check_cflags___O2=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___O2" >&5
printf "%s\n" "$ax_cv_check_cflags___O2" >&6; }
if test "x$ax_cv_check_cflags___O2" = xyes
then :
CFLAGS="$CFLAGS -O2"
else $as_nop
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -O1" >&5
printf %s "checking whether C compiler accepts -O1... " >&6; }
if test ${ax_cv_check_cflags___O1+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -O1"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <time.h>
int
main (void)
{
time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ax_cv_check_cflags___O1=yes
else $as_nop
ax_cv_check_cflags___O1=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___O1" >&5
printf "%s\n" "$ax_cv_check_cflags___O1" >&6; }
if test "x$ax_cv_check_cflags___O1" = xyes
then :
CFLAGS="$CFLAGS -O1"
else $as_nop
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -O" >&5
printf %s "checking whether C compiler accepts -O... " >&6; }
if test ${ax_cv_check_cflags___O+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -O"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <time.h>
int
main (void)
{
time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ax_cv_check_cflags___O=yes
else $as_nop
ax_cv_check_cflags___O=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___O" >&5
printf "%s\n" "$ax_cv_check_cflags___O" >&6; }
if test "x$ax_cv_check_cflags___O" = xyes
then :
CFLAGS="$CFLAGS -O"
else $as_nop
:
fi
fi
fi
fi
fi
fi
# Check whether --enable-ssp was given.
if test ${enable_ssp+y}
then :
@ -6869,46 +7072,6 @@ then :
if test "x$enableval" = "xyes"
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Ofast" >&5
printf %s "checking whether C compiler accepts -Ofast... " >&6; }
if test ${ax_cv_check_cflags___Ofast+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -Ofast"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <time.h>
int
main (void)
{
time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ax_cv_check_cflags___Ofast=yes
else $as_nop
ax_cv_check_cflags___Ofast=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Ofast" >&5
printf "%s\n" "$ax_cv_check_cflags___Ofast" >&6; }
if test "x$ax_cv_check_cflags___Ofast" = xyes
then :
CFLAGS="$CFLAGS -Ofast"
else $as_nop
:
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -ftree-vectorize" >&5
printf %s "checking whether C compiler accepts -ftree-vectorize... " >&6; }
if test ${ax_cv_check_cflags___ftree_vectorize+y}
@ -7069,6 +7232,46 @@ else $as_nop
:
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mtune=native" >&5
printf %s "checking whether C compiler accepts -mtune=native... " >&6; }
if test ${ax_cv_check_cflags___mtune_native+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS -mtune=native"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <time.h>
int
main (void)
{
time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ax_cv_check_cflags___mtune_native=yes
else $as_nop
ax_cv_check_cflags___mtune_native=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___mtune_native" >&5
printf "%s\n" "$ax_cv_check_cflags___mtune_native" >&6; }
if test "x$ax_cv_check_cflags___mtune_native" = xyes
then :
CFLAGS="$CFLAGS -mtune=native"
else $as_nop
:
fi
fi
@ -8458,8 +8661,6 @@ esac
fi
as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags__$CFLAGS -Wall" | $as_tr_sh`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $CFLAGS -Wall" >&5
printf %s "checking whether C compiler accepts $CFLAGS -Wall... " >&6; }
@ -8502,16 +8703,16 @@ else $as_nop
:
fi
as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags__$CFLAGS -Wextra" | $as_tr_sh`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $CFLAGS -Wextra" >&5
printf %s "checking whether C compiler accepts $CFLAGS -Wextra... " >&6; }
as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags__$CFLAGS -Wno-unknown-pragmas" | $as_tr_sh`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $CFLAGS -Wno-unknown-pragmas" >&5
printf %s "checking whether C compiler accepts $CFLAGS -Wno-unknown-pragmas... " >&6; }
if eval test \${$as_CACHEVAR+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS $CFLAGS -Wextra"
CFLAGS="$CFLAGS $CFLAGS -Wno-unknown-pragmas"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <time.h>
@ -8539,12 +8740,14 @@ eval ac_res=\$$as_CACHEVAR
printf "%s\n" "$ac_res" >&6; }
if eval test \"x\$"$as_CACHEVAR"\" = x"yes"
then :
CWFLAGS="$CFLAGS -Wextra"
CFLAGS="$CFLAGS -Wno-unknown-pragmas"
else $as_nop
:
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clang" >&5
printf %s "checking for clang... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@ -8555,7 +8758,7 @@ main (void)
{
#ifndef __clang__
#error Not clang
#error Not clang nor zig cc
#endif
;
@ -8616,6 +8819,90 @@ printf "%s\n" "no" >&6; }
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags__$CWFLAGS -Wextra" | $as_tr_sh`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $CWFLAGS -Wextra" >&5
printf %s "checking whether C compiler accepts $CWFLAGS -Wextra... " >&6; }
if eval test \${$as_CACHEVAR+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS $CWFLAGS -Wextra"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <time.h>
int
main (void)
{
time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
eval "$as_CACHEVAR=yes"
else $as_nop
eval "$as_CACHEVAR=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
eval ac_res=\$$as_CACHEVAR
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
printf "%s\n" "$ac_res" >&6; }
if eval test \"x\$"$as_CACHEVAR"\" = x"yes"
then :
CWFLAGS="$WCFLAGS -Wextra"
else $as_nop
:
fi
as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags__$CWFLAGS -Warray-bounds" | $as_tr_sh`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $CWFLAGS -Warray-bounds" >&5
printf %s "checking whether C compiler accepts $CWFLAGS -Warray-bounds... " >&6; }
if eval test \${$as_CACHEVAR+y}
then :
printf %s "(cached) " >&6
else $as_nop
ax_check_save_flags=$CFLAGS
CFLAGS="$CFLAGS $CWFLAGS -Warray-bounds"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <time.h>
int
main (void)
{
time_t x; int fodder = 0; if (fodder > -1000 && time(&x)) return (int) x
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
eval "$as_CACHEVAR=yes"
else $as_nop
eval "$as_CACHEVAR=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$ax_check_save_flags
fi
eval ac_res=\$$as_CACHEVAR
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
printf "%s\n" "$ac_res" >&6; }
if eval test \"x\$"$as_CACHEVAR"\" = x"yes"
then :
CWFLAGS="$CWFLAGS -Warray-bounds"
else $as_nop
:
fi
as_CACHEVAR=`printf "%s\n" "ax_cv_check_cflags__$CWFLAGS -Wbad-function-cast" | $as_tr_sh`
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $CWFLAGS -Wbad-function-cast" >&5
printf %s "checking whether C compiler accepts $CWFLAGS -Wbad-function-cast... " >&6; }
@ -9905,6 +10192,8 @@ size_t i;
signal(SIGSEGV, sig);
signal(SIGBUS, sig);
#if !defined(__SANITIZE_ADDRESS__) && !defined(__EMSCRIPTEN__)
*((volatile unsigned char *) -1) = 0xd0;
*((volatile unsigned char *) 1) = 0xd0;
for (i = 0; i < 10000000; i += 1024) { x[-i] = x[i] = (unsigned char) i; }
#endif
free((void *) x);
@ -20630,6 +20919,12 @@ then :
printf "%s\n" "#define HAVE_NANOSLEEP 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
if test "x$ac_cv_func_clock_gettime" = xyes
then :
printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
fi
if test "x$WASI" = "x"
@ -20646,6 +20941,12 @@ if test "x$ac_cv_func_explicit_bzero" = xyes
then :
printf "%s\n" "#define HAVE_EXPLICIT_BZERO 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "memset_explicit" "ac_cv_func_memset_explicit"
if test "x$ac_cv_func_memset_explicit" = xyes
then :
printf "%s\n" "#define HAVE_MEMSET_EXPLICIT 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "explicit_memset" "ac_cv_func_explicit_memset"
if test "x$ac_cv_func_explicit_memset" = xyes

View File

@ -42,10 +42,23 @@ AS_IF([pwd | fgrep ' ' > /dev/null 2>&1],
[AC_MSG_ERROR([The build directory contains whitespaces - This can cause tests/installation to fail due to limitations of some libtool versions])]
)
sodium_CFLAGS=${CFLAGS+set}
: ${CFLAGS=""}
AC_PROG_CC
AM_PROG_AS
AC_USE_SYSTEM_EXTENSIONS
dnl Default optimization flags
if test "$sodium_CFLAGS" != "set" ; then
AX_CHECK_COMPILE_FLAG([-Ofast], [CFLAGS="$CFLAGS -Ofast"],
[AX_CHECK_COMPILE_FLAG([-O3], [CFLAGS="$CFLAGS -O3"],
[AX_CHECK_COMPILE_FLAG([-O2], [CFLAGS="$CFLAGS -O2"],
[AX_CHECK_COMPILE_FLAG([-O1], [CFLAGS="$CFLAGS -O1"],
[AX_CHECK_COMPILE_FLAG([-O], [CFLAGS="$CFLAGS -O"])])])])])
fi
dnl Switches
AC_ARG_ENABLE(ssp,
@ -197,11 +210,11 @@ AC_ARG_ENABLE(opt,
[AS_HELP_STRING(--enable-opt,Optimize for the native CPU - The resulting library will be faster but not portable)],
[
AS_IF([test "x$enableval" = "xyes"], [
AX_CHECK_COMPILE_FLAG([-Ofast], [CFLAGS="$CFLAGS -Ofast"])
AX_CHECK_COMPILE_FLAG([-ftree-vectorize], [CFLAGS="$CFLAGS -ftree-vectorize"])
AX_CHECK_COMPILE_FLAG([-ftree-slp-vectorize], [CFLAGS="$CFLAGS -ftree-slp-vectorize"])
AX_CHECK_COMPILE_FLAG([-fomit-frame-pointer], [CFLAGS="$CFLAGS -fomit-frame-pointer"])
AX_CHECK_COMPILE_FLAG([-march=native], [CFLAGS="$CFLAGS -march=native"])
AX_CHECK_COMPILE_FLAG([-mtune=native], [CFLAGS="$CFLAGS -mtune=native"])
])
])
@ -310,15 +323,15 @@ AS_CASE([$host_os],
])
])
AC_ARG_VAR([CWFLAGS], [define to compilation flags for generating extra warnings])
AX_CHECK_COMPILE_FLAG([$CFLAGS -Wall], [CWFLAGS="$CFLAGS -Wall"])
AX_CHECK_COMPILE_FLAG([$CFLAGS -Wextra], [CWFLAGS="$CFLAGS -Wextra"])
AX_CHECK_COMPILE_FLAG([$CFLAGS -Wno-unknown-pragmas], [CFLAGS="$CFLAGS -Wno-unknown-pragmas"])
AC_ARG_VAR([CWFLAGS], [compilation flags for generating extra warnings])
AC_MSG_CHECKING(for clang)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
#ifndef __clang__
#error Not clang
#error Not clang nor zig cc
#endif
]])],
[AC_MSG_RESULT(yes)
@ -328,6 +341,8 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
[AC_MSG_RESULT(no)
])
AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wextra], [CWFLAGS="$WCFLAGS -Wextra"])
AX_CHECK_COMPILE_FLAG([$CWFLAGS -Warray-bounds], [CWFLAGS="$CWFLAGS -Warray-bounds"])
AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wbad-function-cast], [CWFLAGS="$CWFLAGS -Wbad-function-cast"])
AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wcast-qual], [CWFLAGS="$CWFLAGS -Wcast-qual"])
AX_CHECK_COMPILE_FLAG([$CWFLAGS -Wdiv-by-zero], [CWFLAGS="$CWFLAGS -Wdiv-by-zero"])
@ -866,10 +881,10 @@ AS_IF([test "x$WASI" = "x"],[
AC_CHECK_FUNCS([getauxva elf_aux_info])
])
AC_CHECK_FUNCS([posix_memalign nanosleep])
AC_CHECK_FUNCS([posix_memalign nanosleep clock_gettime])
AS_IF([test "x$WASI" = "x"],[
AC_CHECK_FUNCS([memset_s explicit_bzero explicit_memset])
AC_CHECK_FUNCS([memset_s explicit_bzero memset_explicit explicit_memset])
])
AC_SUBST([LIBTOOL_EXTRA_FLAGS])

Some files were not shown because too many files have changed in this diff Show More