]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/s390/s390-64/utf8-utf32-z9.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / s390 / s390-64 / utf8-utf32-z9.c
index 17ef8bc890c39e5b383fe99826cc1a05c0cccecc..defd47d2513a937b6eccc5ce1cace6319c58f935 100644 (file)
@@ -2,7 +2,7 @@
 
    This module uses the Z9-109 variants of the Convert Unicode
    instructions.
-   Copyright (C) 1997-2009 Free Software Foundation, Inc.
+   Copyright (C) 1997-2016 Free Software Foundation, Inc.
 
    Author: Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
    Based on the work by Ulrich Drepper  <drepper@cygnus.com>, 1997.
@@ -21,9 +21,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <dlfcn.h>
 #include <stdint.h>
@@ -45,6 +44,7 @@
 #define FROM_LOOP              from_utf8_loop
 #define TO_LOOP                        to_utf8_loop
 #define FROM_DIRECTION         (dir == from_utf8)
+#define ONE_DIRECTION           0
 #define PREPARE_LOOP                                                   \
   enum direction dir = ((struct utf8_data *) step->__data)->dir;       \
   int emit_bom = ((struct utf8_data *) step->__data)->emit_bom;                \
@@ -53,7 +53,7 @@
       && data->__invocation_counter == 0)                              \
     {                                                                  \
       /* Emit the Byte Order Mark.  */                                 \
-      if (__builtin_expect (outbuf + 4 > outend, 0))                   \
+      if (__glibc_unlikely (outbuf + 4 > outend))                            \
        return __GCONV_FULL_OUTPUT;                                     \
                                                                        \
       put32u (outbuf, BOM);                                            \
@@ -149,19 +149,22 @@ gconv_end (struct __gconv_step *data)
    directions.  */
 #define HARDWARE_CONVERT(INSTRUCTION)                                  \
   {                                                                    \
-    register const unsigned char* pInput asm ("8") = inptr;            \
-    register unsigned long long inlen asm ("9") = inend - inptr;       \
-    register unsigned char* pOutput asm ("10") = outptr;               \
-    register unsigned long long outlen asm("11") = outend - outptr;    \
+    register const unsigned char* pInput __asm__ ("8") = inptr;                \
+    register unsigned long long inlen __asm__ ("9") = inend - inptr;   \
+    register unsigned char* pOutput __asm__ ("10") = outptr;           \
+    register unsigned long long outlen __asm__("11") = outend - outptr;        \
     uint64_t cc = 0;                                                   \
                                                                        \
-    asm volatile ("0: " INSTRUCTION "  \n\t"                           \
-                  "   jo     0b        \n\t"                           \
-                 "   ipm    %2        \n"                              \
-                 : "+a" (pOutput), "+a" (pInput), "+d" (cc),           \
-                   "+d" (outlen), "+d" (inlen)                         \
-                 :                                                     \
-                 : "cc", "memory");                                    \
+    __asm__ volatile (".machine push       \n\t"                       \
+                     ".machine \"z9-109\" \n\t"                        \
+                     "0: " INSTRUCTION "  \n\t"                        \
+                     ".machine pop        \n\t"                        \
+                     "   jo     0b        \n\t"                        \
+                     "   ipm    %2        \n"                          \
+                     : "+a" (pOutput), "+a" (pInput), "+d" (cc),       \
+                     "+d" (outlen), "+d" (inlen)                       \
+                     :                                                 \
+                     : "cc", "memory");                                \
                                                                        \
     inptr = pInput;                                                    \
     outptr = pOutput;                                                  \
@@ -199,7 +202,7 @@ gconv_end (struct __gconv_step *data)
              if ((inptr[i] & 0xc0) != 0x80)                            \
                break;                                                  \
                                                                        \
-           if (__builtin_expect (inptr + i == inend, 1))               \
+           if (__glibc_likely (inptr + i == inend))                          \
              {                                                         \
                result = __GCONV_INCOMPLETE_INPUT;                      \
                break;                                                  \
@@ -212,7 +215,7 @@ gconv_end (struct __gconv_step *data)
     /* Next input byte.  */                                            \
     uint32_t ch = *inptr;                                              \
                                                                        \
-    if (__builtin_expect (ch < 0x80, 1))                               \
+    if (__glibc_likely (ch < 0x80))                                          \
       {                                                                        \
        /* One byte sequence.  */                                       \
        ++inptr;                                                        \
@@ -230,25 +233,25 @@ gconv_end (struct __gconv_step *data)
            cnt = 2;                                                    \
            ch &= 0x1f;                                                 \
          }                                                             \
-        else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1))            \
+        else if (__glibc_likely ((ch & 0xf0) == 0xe0))                       \
          {                                                             \
            /* We expect three bytes.  */                               \
            cnt = 3;                                                    \
            ch &= 0x0f;                                                 \
          }                                                             \
-       else if (__builtin_expect ((ch & 0xf8) == 0xf0, 1))             \
+       else if (__glibc_likely ((ch & 0xf8) == 0xf0))                        \
          {                                                             \
            /* We expect four bytes.  */                                \
            cnt = 4;                                                    \
            ch &= 0x07;                                                 \
          }                                                             \
-       else if (__builtin_expect ((ch & 0xfc) == 0xf8, 1))             \
+       else if (__glibc_likely ((ch & 0xfc) == 0xf8))                        \
          {                                                             \
            /* We expect five bytes.  */                                \
            cnt = 5;                                                    \
            ch &= 0x03;                                                 \
          }                                                             \
-       else if (__builtin_expect ((ch & 0xfe) == 0xfc, 1))             \
+       else if (__glibc_likely ((ch & 0xfe) == 0xfc))                        \
          {                                                             \
            /* We expect six bytes.  */                                 \
            cnt = 6;                                                    \
@@ -269,7 +272,7 @@ gconv_end (struct __gconv_step *data)
            STANDARD_FROM_LOOP_ERR_HANDLER (i);                         \
          }                                                             \
                                                                        \
-       if (__builtin_expect (inptr + cnt > inend, 0))                  \
+       if (__glibc_unlikely (inptr + cnt > inend))                           \
          {                                                             \
            /* We don't have enough input.  But before we report        \
               that check that all the bytes are correct.  */           \
@@ -277,7 +280,7 @@ gconv_end (struct __gconv_step *data)
              if ((inptr[i] & 0xc0) != 0x80)                            \
                break;                                                  \
                                                                        \
-           if (__builtin_expect (inptr + i == inend, 1))               \
+           if (__glibc_likely (inptr + i == inend))                          \
              {                                                         \
                result = __GCONV_INCOMPLETE_INPUT;                      \
                break;                                                  \
@@ -336,19 +339,19 @@ gconv_end (struct __gconv_step *data)
        cnt = 2;                                                              \
        ch &= 0x1f;                                                           \
       }                                                                              \
-    else if (__builtin_expect ((ch & 0xf0) == 0xe0, 1))                              \
+    else if (__glibc_likely ((ch & 0xf0) == 0xe0))                           \
       {                                                                              \
        /* We expect three bytes.  */                                         \
        cnt = 3;                                                              \
        ch &= 0x0f;                                                           \
       }                                                                              \
-    else if (__builtin_expect ((ch & 0xf8) == 0xf0, 1))                              \
+    else if (__glibc_likely ((ch & 0xf8) == 0xf0))                           \
       {                                                                              \
        /* We expect four bytes.  */                                          \
        cnt = 4;                                                              \
        ch &= 0x07;                                                           \
       }                                                                              \
-    else if (__builtin_expect ((ch & 0xfc) == 0xf8, 1))                              \
+    else if (__glibc_likely ((ch & 0xfc) == 0xf8))                           \
       {                                                                              \
        /* We expect five bytes.  */                                          \
        cnt = 5;                                                              \
@@ -429,7 +432,7 @@ gconv_end (struct __gconv_step *data)
                                                                \
     uint32_t wc = *((const uint32_t *) inptr);                 \
                                                                \
-    if (__builtin_expect (wc <= 0x7f, 1))                      \
+    if (__glibc_likely (wc <= 0x7f))                                         \
       {                                                                \
         /* Single UTF-8 char.  */                              \
         *outptr = (uint8_t)wc;                                 \
@@ -438,7 +441,7 @@ gconv_end (struct __gconv_step *data)
     else if (wc <= 0x7ff)                                      \
       {                                                                \
         /* Two UTF-8 chars.  */                                        \
-        if (__builtin_expect (outptr + 2 > outend, 0))         \
+        if (__glibc_unlikely (outptr + 2 > outend))                          \
          {                                                     \
            /* Overflow in the output buffer.  */               \
            result = __GCONV_FULL_OUTPUT;                       \
@@ -456,7 +459,7 @@ gconv_end (struct __gconv_step *data)
     else if (wc <= 0xffff)                                     \
       {                                                                \
        /* Three UTF-8 chars.  */                               \
-       if (__builtin_expect (outptr + 3 > outend, 0))          \
+       if (__glibc_unlikely (outptr + 3 > outend))                           \
          {                                                     \
            /* Overflow in the output buffer.  */               \
            result = __GCONV_FULL_OUTPUT;                       \
@@ -476,7 +479,7 @@ gconv_end (struct __gconv_step *data)
       else if (wc <= 0x10ffff)                                 \
        {                                                       \
          /* Four UTF-8 chars.  */                              \
-         if (__builtin_expect (outptr + 4 > outend, 0))        \
+         if (__glibc_unlikely (outptr + 4 > outend))                         \
            {                                                   \
              /* Overflow in the output buffer.  */             \
              result = __GCONV_FULL_OUTPUT;                     \