Changeset bc56f30 in mainline for uspace/lib/cpp/src


Ignore:
Timestamp:
2019-05-27T12:38:26Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0d14c25
Parents:
4d51c60
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-13 16:06:49)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-05-27 12:38:26)
Message:

Make some libc and libposix headers usable in C++

These headers either get included from standard C++ headers,
or are standard themselves, which means any unnamespaced nonstandard
identifiers are a problem. This commit attempts to fix those
issues, and removes hacks previously used in libcpp to work around it.

Location:
uspace/lib/cpp/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/src/stdexcept.cpp

    r4d51c60 rbc56f30  
    3131#include <stdexcept>
    3232#include <string>
     33#include <str.h>
    3334
    3435namespace std
    3536{
    3637    logic_error::logic_error(const string& what)
    37         : what_{hel::str_dup(what.c_str())}
     38        : what_{::helenos::str_dup(what.c_str())}
    3839    { /* DUMMY BODY */ }
    3940
    4041    logic_error::logic_error(const char* what)
    41         : what_{hel::str_dup(what)}
     42        : what_{::helenos::str_dup(what)}
    4243    { /* DUMMY BODY */ }
    4344
    4445    logic_error::logic_error(const logic_error& other) noexcept
    45         : exception{other}, what_{hel::str_dup(other.what_)}
     46        : exception{other}, what_{::helenos::str_dup(other.what_)}
    4647    { /* DUMMY BODY */ }
    4748
     
    5051        if (what_)
    5152            free(what_);
    52         what_ = hel::str_dup(other.what_);
     53        what_ = ::helenos::str_dup(other.what_);
    5354
    5455        return *this;
     
    114115
    115116    runtime_error::runtime_error(const string& what)
    116         : what_{hel::str_dup(what.c_str())}
     117        : what_{::helenos::str_dup(what.c_str())}
    117118    { /* DUMMY BODY */ }
    118119
    119120    runtime_error::runtime_error(const char* what)
    120         : what_{hel::str_dup(what)}
     121        : what_{::helenos::str_dup(what)}
    121122    { /* DUMMY BODY */ }
    122123
    123124    runtime_error::runtime_error(const runtime_error& other) noexcept
    124         : exception{other}, what_{hel::str_dup(other.what_)}
     125        : exception{other}, what_{::helenos::str_dup(other.what_)}
    125126    { /* DUMMY BODY */ }
    126127
     
    129130        if (what_)
    130131            free(what_);
    131         what_ = hel::str_dup(other.what_);
     132        what_ = ::helenos::str_dup(other.what_);
    132133
    133134        return *this;
  • uspace/lib/cpp/src/string.cpp

    r4d51c60 rbc56f30  
    4242    {
    4343        char* end;
    44         long result = hel::strtol(str.c_str(), &end, base);
     44        long result = ::strtol(str.c_str(), &end, base);
    4545
    4646        if (end != str.c_str())
     
    5858    {
    5959        char* end;
    60         unsigned long result = hel::strtoul(str.c_str(), &end, base);
     60        unsigned long result = ::strtoul(str.c_str(), &end, base);
    6161
    6262        if (end != str.c_str())
     
    106106    }
    107107
    108     namespace hel
    109     {
    110         extern "C" int asprintf(char**, const char*, ...);
    111     }
    112 
    113108    string to_string(int val)
    114109    {
    115110        char* tmp;
    116         hel::asprintf(&tmp, "%d", val);
     111        ::asprintf(&tmp, "%d", val);
    117112
    118113        std::string res{tmp};
     
    125120    {
    126121        char* tmp;
    127         hel::asprintf(&tmp, "%u", val);
     122        ::asprintf(&tmp, "%u", val);
    128123
    129124        std::string res{tmp};
     
    136131    {
    137132        char* tmp;
    138         hel::asprintf(&tmp, "%ld", val);
     133        ::asprintf(&tmp, "%ld", val);
    139134
    140135        std::string res{tmp};
     
    147142    {
    148143        char* tmp;
    149         hel::asprintf(&tmp, "%lu", val);
     144        ::asprintf(&tmp, "%lu", val);
    150145
    151146        std::string res{tmp};
     
    158153    {
    159154        char* tmp;
    160         hel::asprintf(&tmp, "%lld", val);
     155        ::asprintf(&tmp, "%lld", val);
    161156
    162157        std::string res{tmp};
     
    169164    {
    170165        char* tmp;
    171         hel::asprintf(&tmp, "%llu", val);
     166        ::asprintf(&tmp, "%llu", val);
    172167
    173168        std::string res{tmp};
     
    180175    {
    181176        char* tmp;
    182         hel::asprintf(&tmp, "%f", val);
     177        ::asprintf(&tmp, "%f", val);
    183178
    184179        std::string res{tmp};
     
    191186    {
    192187        char* tmp;
    193         hel::asprintf(&tmp, "%f", val);
     188        ::asprintf(&tmp, "%f", val);
    194189
    195190        std::string res{tmp};
     
    202197    {
    203198        char* tmp;
    204         hel::asprintf(&tmp, "%Lf", val);
     199        ::asprintf(&tmp, "%Lf", val);
    205200
    206201        std::string res{tmp};
  • uspace/lib/cpp/src/typeinfo.cpp

    r4d51c60 rbc56f30  
    3838    bool type_info::operator==(const type_info& other) const noexcept
    3939    {
    40         return (this == &other) ||
    41                std::hel::str_cmp(name(), other.name());
     40        return (this == &other) || ::strcmp(name(), other.name()) == 0;
    4241    }
    4342
Note: See TracChangeset for help on using the changeset viewer.