All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: "Collin L. Walling" <walling@linux.vnet.ibm.com>
Cc: borntraeger@de.ibm.com, frankja@linux.vnet.ibm.com,
	qemu-s390x@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v1 1/5] s390-ccw: update libc.h
Date: Tue, 28 Nov 2017 11:45:58 +0100	[thread overview]
Message-ID: <20171128114558.5284f736.cohuck@redhat.com> (raw)
In-Reply-To: <1511816136-30068-2-git-send-email-walling@linux.vnet.ibm.com>

On Mon, 27 Nov 2017 15:55:32 -0500
"Collin L. Walling" <walling@linux.vnet.ibm.com> wrote:

> Moved:
>   memcmp from bootmap.h to libc.h (renamed from _memcmp)
>   strlen from sclp.c to libc.h (renamed from _strlen)
> 
> Added C standard functions:
>   isdigit
>   atoi
> 
> Added non-C standard function:
>   itostr
> 
> Signed-off-by: Collin L. Walling <walling@linux.vnet.ibm.com>
> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> Reviewed-by: frankja@linux.vnet.ibm.com

You might want to include Janosch's complete name :)

> ---
>  pc-bios/s390-ccw/bootmap.c |  4 +-
>  pc-bios/s390-ccw/bootmap.h | 16 +-------
>  pc-bios/s390-ccw/libc.h    | 94 ++++++++++++++++++++++++++++++++++++++++++++++
>  pc-bios/s390-ccw/main.c    | 17 +--------
>  pc-bios/s390-ccw/sclp.c    | 10 +----
>  5 files changed, 99 insertions(+), 42 deletions(-)
> 

> diff --git a/pc-bios/s390-ccw/libc.h b/pc-bios/s390-ccw/libc.h
> index 0142ea8..703c34d 100644
> --- a/pc-bios/s390-ccw/libc.h
> +++ b/pc-bios/s390-ccw/libc.h

(...)

> +/* itostr
> + *
> + * Given an integer, convert it to a string. The string must be allocated
> + * beforehand. The resulting string will be null terminated and returned.
> + *
> + * @str - the integer to be converted
> + * @num - a pointer to a string to store the conversion
> + *
> + * @return - the string of the converted integer
> + */

That one's a bit unusual as it does not match the semantics of any
library function I'd normally use for that kind of thing, but it seems
to do the job and more would be overkill, so fine with me.

> +static inline char *itostr(int num, char *str)
> +{
> +    int i;
> +    int len = 0;
> +    long tens = 1;
> +
> +    /* Handle 0 */
> +    if (num == 0) {
> +        str[0] = '0';
> +        str[1] = '\0';
> +        return str;
> +    }
> +
> +    /* Count number of digits */
> +    while (num / tens != 0) {
> +        tens *= 10;
> +        len++;
> +    }
> +
> +    /* Convert int -> string */
> +    for (i = 0; i < len; i++) {
> +        tens /= 10;
> +        str[i] = num / tens % 10 + '0';
> +    }
> +
> +    str[i] = '\0';
> +
> +    return str;
> +}
> +
>  #endif

  reply	other threads:[~2017-11-28 10:46 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27 20:55 [Qemu-devel] [PATCH v1 0/5] (FIXED) Interactive Boot Menu for DASD and SCSI Guests on s390x Collin L. Walling
2017-11-27 20:55 ` [Qemu-devel] [PATCH v1 1/5] s390-ccw: update libc.h Collin L. Walling
2017-11-28 10:45   ` Cornelia Huck [this message]
2017-11-28 15:36     ` [Qemu-devel] [qemu-s390x] " Collin L. Walling
2017-11-28 11:32   ` Thomas Huth
2017-11-27 20:55 ` [Qemu-devel] [PATCH v1 2/5] s390-ccw: ipl structs for eckd cdl/ldl Collin L. Walling
2017-11-28 10:48   ` Cornelia Huck
2017-11-28 15:42     ` [Qemu-devel] [qemu-s390x] " Collin L. Walling
2017-11-28 16:41       ` Cornelia Huck
2017-11-27 20:55 ` [Qemu-devel] [PATCH v1 3/5] s390-ccw: parse and set boot menu options Collin L. Walling
2017-11-28 11:04   ` Cornelia Huck
2017-11-28 16:00     ` [Qemu-devel] [qemu-s390x] " Collin L. Walling
2017-11-28 11:45   ` Thomas Huth
2017-11-28 16:02     ` Collin L. Walling
2017-11-29 22:28   ` David Hildenbrand
2017-11-29 22:33     ` Collin L. Walling
2017-11-30 15:52       ` David Hildenbrand
2017-11-30 16:05         ` Cornelia Huck
2017-11-27 20:55 ` [Qemu-devel] [PATCH v1 4/5] s390-ccw: interactive boot menu for eckd dasd Collin L. Walling
2017-11-28 12:36   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2017-11-28 12:45     ` Cornelia Huck
2017-11-28 16:31     ` Collin L. Walling
2017-11-27 20:55 ` [Qemu-devel] [PATCH v1 5/5] s390-ccw: interactive boot menu for scsi Collin L. Walling
2017-11-28 10:35 ` [Qemu-devel] [PATCH v1 0/5] (FIXED) Interactive Boot Menu for DASD and SCSI Guests on s390x Cornelia Huck
2017-11-28 16:35   ` [Qemu-devel] [qemu-s390x] " Collin L. Walling
2017-11-28 16:42     ` Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171128114558.5284f736.cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=frankja@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=walling@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.