Ignore:
Timestamp:
Apr 24, 2021, 11:32:49 AM (5 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
424dfc4, 986cb99
Parents:
fec63b2 (diff), 8edbe40 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/http/protocol.cfa

    rfec63b2 r50f6afb  
    55        #include <fcntl.h>
    66}
     7
     8#define xstr(s) str(s)
     9#define str(s) #s
    710
    811#include <fstream.hfa>
     
    2124
    2225#define PLAINTEXT_1WRITE
     26#define PLAINTEXT_MEMCPY
    2327#define PLAINTEXT_NOCOPY
    2428
     
    8589#if defined(PLAINTEXT_NOCOPY)
    8690int answer_plaintext( int fd ) {
    87         return answer(fd, http_msgs[OK200_PlainText]->msg, http_msgs[OK200_PlainText]->len + 1); // +1 cause snprintf doesn't count nullterminator
     91        return answer(fd, http_msgs[OK200_PlainText]->msg, http_msgs[OK200_PlainText]->len); // +1 cause snprintf doesn't count nullterminator
     92}
     93#elif defined(PLAINTEXT_MEMCPY)
     94#define TEXTSIZE 15
     95int answer_plaintext( int fd ) {
     96        char text[] = "Hello, World!\n\n";
     97        char ts[] = xstr(TEXTSIZE) " \n\n";
     98        _Static_assert(sizeof(text) - 1 == TEXTSIZE);
     99        char buffer[512 + TEXTSIZE];
     100        char * it = buffer;
     101        memcpy(it, http_msgs[OK200]->msg, http_msgs[OK200]->len);
     102        it += http_msgs[OK200]->len;
     103        int len = http_msgs[OK200]->len;
     104        memcpy(it, ts, sizeof(ts) - 1);
     105        it += sizeof(ts) - 1;
     106        len += sizeof(ts) - 1;
     107        memcpy(it, text, TEXTSIZE);
     108        return answer(fd, buffer, len + TEXTSIZE);
    88109}
    89110#elif defined(PLAINTEXT_1WRITE)
    90111int answer_plaintext( int fd ) {
    91         char text[] = "Hello, World!\n";
     112        char text[] = "Hello, World!\n\n";
    92113        char buffer[512 + sizeof(text)];
    93114        char * it = buffer;
     
    103124#else
    104125int answer_plaintext( int fd ) {
    105         char text[] = "Hello, World!\n";
     126        char text[] = "Hello, World!\n\n";
    106127        int ret = answer_header(fd, sizeof(text));
    107128        if( ret < 0 ) return ret;
     
    194215const char * original_http_msgs[] = {
    195216        "HTTP/1.1 200 OK\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: ",
    196         "HTTP/1.1 200 OK\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 15\n\nHello, World!\n",
     217        "HTTP/1.1 200 OK\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 15\n\nHello, World!\n\n",
    197218        "HTTP/1.1 400 Bad Request\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
    198219        "HTTP/1.1 404 Not Found\nServer: HttoForall\nDate: %s \nContent-Type: text/plain\nContent-Length: 0 \n\n",
Note: See TracChangeset for help on using the changeset viewer.