Skip to content

Commit

Permalink
POSIX backed support on FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
artyom-beilis committed Sep 30, 2015
1 parent 6231333 commit b7fcbdc
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/encoding/iconv_codepage.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ public:
res = conv(0,0,&out_ptr,&out_left);

int err = errno;

size_t output_count = (out_ptr - out_start) / sizeof(OutChar);

if(res!=0 && res!=(size_t)(-1)) {
if(how_ == stop) {
throw conversion_error();
}
}

sresult.append(&result[0],output_count);

Expand Down Expand Up @@ -166,7 +172,6 @@ public:

};


template<typename CharType>
class iconv_to_utf : public iconverter_base, public converter_to_utf<CharType>
{
Expand All @@ -188,7 +193,6 @@ public:




} // impl
} // conv
} // locale
Expand Down
2 changes: 1 addition & 1 deletion src/posix/numeric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ struct basic_numpunct {
}
basic_numpunct(locale_t lc)
{
#ifdef __APPLE__
#if defined(__APPLE__) || defined(__FreeBSD__)
lconv *cv = localeconv_l(lc);
grouping = cv->grouping;
thousands_sep = cv->thousands_sep;
Expand Down
8 changes: 8 additions & 0 deletions src/util/iconv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

namespace boost {
namespace locale {
#if defined(__ICONV_F_HIDE_INVALID) && defined(__FreeBSD__)
inline size_t call_iconv(iconv_t d,char **in,size_t *insize,char **out,size_t *outsize)
{
char const **rin = const_cast<char const **>(in);
return __iconv(d,rin,insize,out,outsize,__ICONV_F_HIDE_INVALID,0);

This comment has been minimized.

Copy link
@Flast

Flast Oct 10, 2015

This change broke compilations on FreeBSD.

Here is an error message from my regression runner (a.k.a. Flast-FreeBSD10-gcc-4.8.5~gnu++11).

In file included from ../libs/locale/src/encoding/iconv_codepage.ipp:12:0,
                 from ../libs/locale/src/encoding/codepage.cpp:16:
../libs/locale/src/encoding/../util/iconv.hpp: In function 'size_t boost::locale::call_iconv(iconv_t, char**, size_t*, char**, size_t*)':
../libs/locale/src/encoding/../util/iconv.hpp:19:77: error: invalid conversion from 'const char**' to 'char**' [-fpermissive]
             return __iconv(d,rin,insize,out,outsize,__ICONV_F_HIDE_INVALID,0);
                                                                             ^
In file included from ../libs/locale/src/encoding/../util/iconv.hpp:11:0,
                 from ../libs/locale/src/encoding/iconv_codepage.ipp:12,
                 from ../libs/locale/src/encoding/codepage.cpp:16:
/usr/include/iconv.h:65:8: error:   initializing argument 2 of 'size_t __iconv(iconv_t, char**, size_t*, char**, size_t*, __uint32_t, size_t*)' [-fpermissive]
 size_t __iconv(iconv_t, char **, size_t *, char **,

This comment has been minimized.

Copy link
@artyom-beilis

artyom-beilis via email Oct 10, 2015

Author Member

This comment has been minimized.

Copy link
@artyom-beilis

artyom-beilis Oct 12, 2015

Author Member

Can I get a full log of the test run - I'm getting other errors.

I fixed this problem but I see other exits, it works fine on FreeBSD 10.0 with clang but without full build and test log it is very hard to understand what is going on.

This comment has been minimized.

Copy link
@Flast

Flast Oct 15, 2015

Build/test run logs do not help in this situation; exit status 139 on FreeBSD is terminated by SIGSEGV.

The backtrace is here.

> /usr/local/bin/gdb710 /home/freebsd/boost/bin.v2/libs/locale/test/test_boundary.test/gcc-5.2.0/debug/test_boundary
GNU gdb (GDB) 7.10 [GDB v7.10 for FreeBSD]
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd10.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/freebsd/boost/bin.v2/libs/locale/test/test_boundary.test/gcc-5.2.0/debug/test_boundary...done.
(gdb) start
Temporary breakpoint 1 at 0x40e4d3: file test_boundary.cpp, line 516.
Starting program: /home/freebsd/boost/bin.v2/libs/locale/test/test_boundary.test/gcc-5.2.0/debug/test_boundary 
[New Thread 805018400 (LWP 100090)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 805018400 (LWP 100090)]
0x0000000000000000 in ?? ()
(gdb) backtrace
#0  0x0000000000000000 in ?? ()
#1  0x00000008033ee399 in __cxxabiv1::__dynamic_cast (src_ptr=0x8036eaa80 <(anonymous namespace)::ctype_c>, 
    src_type=0x8036de780 <typeinfo for std::locale::facet>, dst_type=0x8036df858 <typeinfo for std::ctype<char>>, 
    src2dst=src2dst@entry=0) at ../../.././../gcc-5.2.0/libstdc++-v3/libsupc++/dyncast.cc:72
#2  0x000000080346bd80 in std::has_facet<std::ctype<char> > (__loc=...)
    at /wrkdirs/usr/ports/lang/gcc5/work/build/x86_64-portbld-freebsd10.1/libstdc++-v3/include/bits/locale_classes.tcc:110
#3  0x000000080345fa94 in std::basic_ios<char, std::char_traits<char> >::_M_cache_locale (
    this=this@entry=0x8036e9768 <std::cout+8>, __loc=...)
    at /wrkdirs/usr/ports/lang/gcc5/work/build/x86_64-portbld-freebsd10.1/libstdc++-v3/include/bits/basic_ios.tcc:159
#4  0x000000080345fc00 in std::basic_ios<char, std::char_traits<char> >::init (this=this@entry=0x8036e9768 <std::cout+8>, 
    __sb=0x8036e9040 <__gnu_internal::buf_cout_sync>)
    at /wrkdirs/usr/ports/lang/gcc5/work/build/x86_64-portbld-freebsd10.1/libstdc++-v3/include/bits/basic_ios.tcc:132
#5  0x0000000803404b91 in std::basic_ostream<char, std::char_traits<char> >::basic_ostream (__sb=<optimized out>, 
    this=<optimized out>, __in_chrg=<optimized out>, __vtt_parm=<optimized out>)
    at /wrkdirs/usr/ports/lang/gcc5/work/build/x86_64-portbld-freebsd10.1/libstdc++-v3/include/ostream:85
#6  std::ios_base::Init::Init (this=<optimized out>) at ../../../.././../gcc-5.2.0/libstdc++-v3/src/c++98/ios_init.cc:91
#7  0x0000000800bf68a4 in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535)
    at /usr/local/lib/gcc5/include/c++/iostream:74
#8  0x0000000800bf68d7 in _GLOBAL__sub_I_chrono.cpp(void) () at ../../../boost/chrono/detail/inlined/posix/chrono.hpp:118
#9  0x000000080064e7a0 in ?? () from /libexec/ld-elf.so.1
#10 0x000000080064dd17 in ?? () from /libexec/ld-elf.so.1
#11 0x000000080064c129 in ?? () from /libexec/ld-elf.so.1
#12 0x0000000000000000 in ?? ()
(gdb)

Hmm...

This comment has been minimized.

Copy link
@artyom-beilis

artyom-beilis via email Oct 15, 2015

Author Member

This comment has been minimized.

Copy link
@Flast

Flast Oct 15, 2015

You must make sure that ICU is built against exactly the same version of gcc/libstdc++ (or at least abi compatible one)Show what ldd test_boundary shows. It may be the case when ICU is built against clang/libstdc++ and boost against libstdc++ of different version Note that on same tester Boost.Regex icu_example fails with 139...I strongly suspect some ABI mixed libraries related issues

Ah, it make sense. ldd shows that ICU is linked to libc++/libcxxrt and the executable is linked to libstdc++(i.e. libsupc++). I installed the ICU via pkgng, thus I should build ICU by hand using libstdc++.

This comment has been minimized.

Copy link
@artyom-beilis

artyom-beilis via email Oct 15, 2015

Author Member
}
#else
extern "C" {
typedef size_t (*gnu_iconv_ptr_type)(iconv_t d,char const **in,size_t *insize,char **out,size_t *outsize);
typedef size_t (*posix_iconv_ptr_type)(iconv_t d,char **in,size_t *insize,char **out,size_t *outsize);
Expand All @@ -29,6 +36,7 @@ namespace boost {
{
return do_iconv( iconv, d, in,insize,out,outsize);
}
#endif

} // locale
} // boost
Expand Down
8 changes: 6 additions & 2 deletions test/test_codepage_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,12 @@ int main()
std::cout << "Testing Shift-JIS using POSIX/iconv" << std::endl;

cvt = boost::locale::impl_posix::create_iconv_converter("Shift-JIS");
TEST(cvt.get());
test_shiftjis(cvt);
if(cvt.get()) {
test_shiftjis(cvt);
}
else {
std::cout<< "- Shift-JIS is not supported!" << std::endl;
}
#endif

}
Expand Down
4 changes: 2 additions & 2 deletions test/test_posix_collate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void test_char()
std::string name;


#ifndef __APPLE__
#if !defined(__APPLE__) && !defined(__FreeBSD__)
std::string names[] = { "en_US.UTF-8", "en_US.ISO8859-1" };
for(unsigned i=0;i<sizeof(names)/sizeof(names[0]);i++) {
if(have_locale(names[i])) {
Expand All @@ -89,7 +89,7 @@ void test_char()
}
}
#else
std::cout << "- Collation is broken in Mac OS X's C standard library, skipping" << std::endl;
std::cout << "- Collation is broken on this OS C standard library, skipping" << std::endl;
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_posix_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void test_char()
std::cout << "Testing " << name << std::endl;
std::locale l=gen(name);
test_one<CharType>(l,"Hello World","hello world","HELLO WORLD");
#ifdef __APPLE__
#if defined(__APPLE__) || defined(__FreeBSD__)
if(sizeof(CharType)!=1)
#endif
test_one<CharType>(l,"Façade","façade","FAÇADE");
Expand Down
4 changes: 4 additions & 0 deletions test/test_std_collate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ void test_char()

std::string name;

#if defined(_LIBCPP_VERSION) && (defined(__APPLE__) || defined(__FreeBSD__))
std::cout << "- Collation is broken on this OS's standard C++ library, skipping" << std::endl;
#else
std::string names[] = { "en_US.UTF-8", "en_US.ISO8859-1" };
for(unsigned i=0;i<sizeof(names)/sizeof(names[0]);i++) {
name = get_std_name(names[i]);
Expand All @@ -87,6 +90,7 @@ void test_char()
std::cout << "- " << names[i] << " not supported, skipping" << std::endl;
}
}
#endif
}


Expand Down

0 comments on commit b7fcbdc

Please sign in to comment.